ffi-tk 2009.11.29

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.
Files changed (189) hide show
  1. data/CHANGELOG +748 -0
  2. data/MANIFEST +188 -0
  3. data/README.md +85 -0
  4. data/Rakefile +47 -0
  5. data/TODO.md +62 -0
  6. data/bin/rwish +33 -0
  7. data/doc/MIT_LICENSE +18 -0
  8. data/doc/TCL_LICENSE +39 -0
  9. data/example/choose_color.rb +22 -0
  10. data/example/choose_directory.rb +22 -0
  11. data/example/dialog.rb +37 -0
  12. data/example/hello.rb +11 -0
  13. data/example/message_box.rb +26 -0
  14. data/example/option_menu.rb +17 -0
  15. data/example/popup.rb +24 -0
  16. data/example/set_palette.rb +32 -0
  17. data/example/text.rb +47 -0
  18. data/example/tile/kroc_demo_small.rb +123 -0
  19. data/example/tile/kroc_rb_demo.rb +135 -0
  20. data/example/tile/notebook.rb +48 -0
  21. data/example/tile/theme_hello.rb +38 -0
  22. data/example/tile/treeview.rb +71 -0
  23. data/example/various.rb +25 -0
  24. data/example/wait.rb +16 -0
  25. data/ffi-tk.gemspec +33 -0
  26. data/lib/ffi-tk.rb +76 -0
  27. data/lib/ffi-tk/command.rb +39 -0
  28. data/lib/ffi-tk/command/after.rb +36 -0
  29. data/lib/ffi-tk/command/bell.rb +34 -0
  30. data/lib/ffi-tk/command/bind.rb +11 -0
  31. data/lib/ffi-tk/command/bindtags.rb +69 -0
  32. data/lib/ffi-tk/command/cget.rb +92 -0
  33. data/lib/ffi-tk/command/choose_color.rb +29 -0
  34. data/lib/ffi-tk/command/choose_directory.rb +45 -0
  35. data/lib/ffi-tk/command/clipboard.rb +102 -0
  36. data/lib/ffi-tk/command/configure.rb +88 -0
  37. data/lib/ffi-tk/command/destroy.rb +12 -0
  38. data/lib/ffi-tk/command/dialog.rb +54 -0
  39. data/lib/ffi-tk/command/event.rb +79 -0
  40. data/lib/ffi-tk/command/focus.rb +70 -0
  41. data/lib/ffi-tk/command/font.rb +124 -0
  42. data/lib/ffi-tk/command/get_open_file.rb +85 -0
  43. data/lib/ffi-tk/command/get_save_file.rb +83 -0
  44. data/lib/ffi-tk/command/grab.rb +141 -0
  45. data/lib/ffi-tk/command/grid.rb +246 -0
  46. data/lib/ffi-tk/command/image.rb +79 -0
  47. data/lib/ffi-tk/command/lower.rb +23 -0
  48. data/lib/ffi-tk/command/message_box.rb +65 -0
  49. data/lib/ffi-tk/command/option_menu.rb +8 -0
  50. data/lib/ffi-tk/command/pack.rb +99 -0
  51. data/lib/ffi-tk/command/place.rb +91 -0
  52. data/lib/ffi-tk/command/popup.rb +14 -0
  53. data/lib/ffi-tk/command/raise.rb +25 -0
  54. data/lib/ffi-tk/command/scrollable.rb +151 -0
  55. data/lib/ffi-tk/command/selection.rb +132 -0
  56. data/lib/ffi-tk/command/set_palette.rb +9 -0
  57. data/lib/ffi-tk/command/tk_cmd.rb +155 -0
  58. data/lib/ffi-tk/command/vars.rb +82 -0
  59. data/lib/ffi-tk/command/wait.rb +39 -0
  60. data/lib/ffi-tk/command/winfo.rb +668 -0
  61. data/lib/ffi-tk/command/wm.rb +1025 -0
  62. data/lib/ffi-tk/core_extensions.rb +154 -0
  63. data/lib/ffi-tk/event/data.rb +60 -0
  64. data/lib/ffi-tk/event/handler.rb +44 -0
  65. data/lib/ffi-tk/ffi/tcl.rb +92 -0
  66. data/lib/ffi-tk/ffi/tcl/cmd_proc.rb +10 -0
  67. data/lib/ffi-tk/ffi/tcl/eval_result.rb +148 -0
  68. data/lib/ffi-tk/ffi/tcl/interp.rb +95 -0
  69. data/lib/ffi-tk/ffi/tcl/obj.rb +89 -0
  70. data/lib/ffi-tk/ffi/tcl/time.rb +36 -0
  71. data/lib/ffi-tk/ffi/tk.rb +35 -0
  72. data/lib/ffi-tk/geometry.rb +32 -0
  73. data/lib/ffi-tk/thread_sender.rb +26 -0
  74. data/lib/ffi-tk/tk.rb +222 -0
  75. data/lib/ffi-tk/variable.rb +46 -0
  76. data/lib/ffi-tk/widget.rb +68 -0
  77. data/lib/ffi-tk/widget/button.rb +41 -0
  78. data/lib/ffi-tk/widget/canvas.rb +806 -0
  79. data/lib/ffi-tk/widget/canvas/arc.rb +18 -0
  80. data/lib/ffi-tk/widget/canvas/bitmap.rb +13 -0
  81. data/lib/ffi-tk/widget/canvas/image.rb +10 -0
  82. data/lib/ffi-tk/widget/canvas/item.rb +170 -0
  83. data/lib/ffi-tk/widget/canvas/line.rb +16 -0
  84. data/lib/ffi-tk/widget/canvas/oval.rb +15 -0
  85. data/lib/ffi-tk/widget/canvas/polygon.rb +16 -0
  86. data/lib/ffi-tk/widget/canvas/rectangle.rb +15 -0
  87. data/lib/ffi-tk/widget/canvas/text.rb +15 -0
  88. data/lib/ffi-tk/widget/canvas/window.rb +11 -0
  89. data/lib/ffi-tk/widget/checkbutton.rb +63 -0
  90. data/lib/ffi-tk/widget/entry.rb +208 -0
  91. data/lib/ffi-tk/widget/frame.rb +12 -0
  92. data/lib/ffi-tk/widget/label.rb +26 -0
  93. data/lib/ffi-tk/widget/labelframe.rb +7 -0
  94. data/lib/ffi-tk/widget/listbox.rb +192 -0
  95. data/lib/ffi-tk/widget/menu.rb +318 -0
  96. data/lib/ffi-tk/widget/menubutton.rb +7 -0
  97. data/lib/ffi-tk/widget/message.rb +36 -0
  98. data/lib/ffi-tk/widget/panedwindow.rb +164 -0
  99. data/lib/ffi-tk/widget/radiobutton.rb +43 -0
  100. data/lib/ffi-tk/widget/root.rb +8 -0
  101. data/lib/ffi-tk/widget/scale.rb +44 -0
  102. data/lib/ffi-tk/widget/scrollbar.rb +114 -0
  103. data/lib/ffi-tk/widget/spinbox.rb +198 -0
  104. data/lib/ffi-tk/widget/text.rb +893 -0
  105. data/lib/ffi-tk/widget/text/peer.rb +10 -0
  106. data/lib/ffi-tk/widget/tile.rb +70 -0
  107. data/lib/ffi-tk/widget/tile/button.rb +8 -0
  108. data/lib/ffi-tk/widget/tile/checkbutton.rb +8 -0
  109. data/lib/ffi-tk/widget/tile/combobox.rb +43 -0
  110. data/lib/ffi-tk/widget/tile/entry.rb +8 -0
  111. data/lib/ffi-tk/widget/tile/frame.rb +13 -0
  112. data/lib/ffi-tk/widget/tile/label.rb +9 -0
  113. data/lib/ffi-tk/widget/tile/labelframe.rb +8 -0
  114. data/lib/ffi-tk/widget/tile/menubutton.rb +8 -0
  115. data/lib/ffi-tk/widget/tile/notebook.rb +93 -0
  116. data/lib/ffi-tk/widget/tile/panedwindow.rb +9 -0
  117. data/lib/ffi-tk/widget/tile/progressbar.rb +59 -0
  118. data/lib/ffi-tk/widget/tile/radiobutton.rb +8 -0
  119. data/lib/ffi-tk/widget/tile/scale.rb +8 -0
  120. data/lib/ffi-tk/widget/tile/scrollbar.rb +41 -0
  121. data/lib/ffi-tk/widget/tile/separator.rb +23 -0
  122. data/lib/ffi-tk/widget/tile/sizegrip.rb +24 -0
  123. data/lib/ffi-tk/widget/tile/style.rb +114 -0
  124. data/lib/ffi-tk/widget/tile/treeview.rb +414 -0
  125. data/lib/ffi-tk/widget/toplevel.rb +14 -0
  126. data/spec/ffi-tk/command/bindtags.rb +18 -0
  127. data/spec/ffi-tk/command/clipboard.rb +18 -0
  128. data/spec/ffi-tk/command/font.rb +67 -0
  129. data/spec/ffi-tk/command/grid.rb +6 -0
  130. data/spec/ffi-tk/command/image.rb +26 -0
  131. data/spec/ffi-tk/command/pack.rb +20 -0
  132. data/spec/ffi-tk/command/place.rb +20 -0
  133. data/spec/ffi-tk/command/selection.rb +13 -0
  134. data/spec/ffi-tk/command/vars.rb +32 -0
  135. data/spec/ffi-tk/command/winfo.rb +233 -0
  136. data/spec/ffi-tk/command/wm.rb +185 -0
  137. data/spec/ffi-tk/event.rb +95 -0
  138. data/spec/ffi-tk/tile/button.rb +51 -0
  139. data/spec/ffi-tk/tile/checkbutton.rb +13 -0
  140. data/spec/ffi-tk/tile/combobox.rb +65 -0
  141. data/spec/ffi-tk/tile/entry.rb +61 -0
  142. data/spec/ffi-tk/tile/frame.rb +65 -0
  143. data/spec/ffi-tk/tile/label.rb +17 -0
  144. data/spec/ffi-tk/tile/labelframe.rb +13 -0
  145. data/spec/ffi-tk/tile/menubutton.rb +13 -0
  146. data/spec/ffi-tk/tile/notebook.rb +103 -0
  147. data/spec/ffi-tk/tile/panedwindow.rb +13 -0
  148. data/spec/ffi-tk/tile/progressbar.rb +78 -0
  149. data/spec/ffi-tk/tile/radiobutton.rb +13 -0
  150. data/spec/ffi-tk/tile/scale.rb +13 -0
  151. data/spec/ffi-tk/tile/scrollbar.rb +43 -0
  152. data/spec/ffi-tk/tile/separator.rb +22 -0
  153. data/spec/ffi-tk/tile/sizegrip.rb +13 -0
  154. data/spec/ffi-tk/tile/style.rb +161 -0
  155. data/spec/ffi-tk/tile/treeview.rb +101 -0
  156. data/spec/ffi-tk/variable.rb +24 -0
  157. data/spec/ffi-tk/widget/button.rb +22 -0
  158. data/spec/ffi-tk/widget/canvas.rb +169 -0
  159. data/spec/ffi-tk/widget/checkbutton.rb +44 -0
  160. data/spec/ffi-tk/widget/entry.rb +155 -0
  161. data/spec/ffi-tk/widget/frame.rb +8 -0
  162. data/spec/ffi-tk/widget/label.rb +16 -0
  163. data/spec/ffi-tk/widget/labelframe.rb +12 -0
  164. data/spec/ffi-tk/widget/listbox.rb +19 -0
  165. data/spec/ffi-tk/widget/menu.rb +12 -0
  166. data/spec/ffi-tk/widget/menubutton.rb +12 -0
  167. data/spec/ffi-tk/widget/message.rb +12 -0
  168. data/spec/ffi-tk/widget/panedwindow.rb +12 -0
  169. data/spec/ffi-tk/widget/radiobutton.rb +12 -0
  170. data/spec/ffi-tk/widget/root.rb +9 -0
  171. data/spec/ffi-tk/widget/scale.rb +12 -0
  172. data/spec/ffi-tk/widget/scrollbar.rb +12 -0
  173. data/spec/ffi-tk/widget/spinbox.rb +12 -0
  174. data/spec/ffi-tk/widget/text.rb +246 -0
  175. data/spec/ffi-tk/widget/toplevel.rb +12 -0
  176. data/spec/helper.rb +3 -0
  177. data/tasks/authors.rake +21 -0
  178. data/tasks/bacon.rake +66 -0
  179. data/tasks/changelog.rake +18 -0
  180. data/tasks/gem.rake +22 -0
  181. data/tasks/gem_setup.rake +113 -0
  182. data/tasks/grancher.rake +12 -0
  183. data/tasks/manifest.rake +4 -0
  184. data/tasks/rcov.rake +17 -0
  185. data/tasks/release.rake +65 -0
  186. data/tasks/reversion.rake +8 -0
  187. data/tasks/setup.rake +12 -0
  188. data/tasks/ycov.rake +84 -0
  189. metadata +261 -0
@@ -0,0 +1,82 @@
1
+ module Tk
2
+ @library = Variable.new('tk_library')
3
+
4
+ @version = Variable.new('tk_version')
5
+ @patchlevel = Variable.new('tk_patchLevel')
6
+
7
+ @strict_motif = Variable.new('tk_strictMotif')
8
+
9
+ @text_redraw = Variable.new('tk_textRedraw')
10
+ @text_relayout = Variable.new('tk_textRelayout')
11
+
12
+ module_function
13
+
14
+ # This variable holds the file name for a directory containing a library of
15
+ # Tcl scripts related to Tk.
16
+ # These scripts include an initialization file that is normally processed
17
+ # whenever a Tk application starts up, plus other files containing procedures
18
+ # that implement default behaviors for widgets.
19
+ # The initial value of tcl_library is set when Tk is added to an interpreter;
20
+ # this is done by searching several different directories until one is found
21
+ # that contains an appropriate Tk startup script.
22
+ # If the TK_LIBRARY environment variable exists, then the directory it names
23
+ # is checked first.
24
+ # If TK_LIBRARY is not set or does not refer to an appropriate directory, then
25
+ # Tk checks several other directories based on a compiled-in default location,
26
+ # the location of the Tcl library directory, the location of the binary
27
+ # containing the application, and the current working directory.
28
+ # The variable can be modified by an application to switch to a different
29
+ # library.
30
+ def library
31
+ @library.to_s
32
+ end
33
+
34
+ def library=(new_library)
35
+ @library.set(new_library.to_s)
36
+ end
37
+
38
+ # Contains a decimal integer giving the current patch level for Tk.
39
+ # The patch level is incremented for each new release or patch, and it
40
+ # uniquely identifies an official version of Tk.
41
+ def patchlevel
42
+ @patchlevel.to_s
43
+ end
44
+
45
+ # This variable is set to zero by default.
46
+ # If an application sets it to one, then Tk attempts to adhere as closely as
47
+ # possible to Motif look-and-feel standards.
48
+ # For example, active elements such as buttons and scrollbar sliders will not
49
+ # change color when the pointer passes over them.
50
+ def strict_motif
51
+ @strict_motif.to_boolean
52
+ end
53
+
54
+ def strict_motif=(new_value)
55
+ @strict_motif.set(new_value ? true : false)
56
+ end
57
+
58
+ # These variables are set by text widgets when they have debugging turned on.
59
+ # The values written to these variables can be used to test or debug text
60
+ # widget operations.
61
+ # These variables are mostly used by Tk's test suite.
62
+ def text_redraw
63
+ @text_redraw.get
64
+ end
65
+
66
+ def text_relayout
67
+ @text_relayout.get
68
+ end
69
+
70
+ # Tk sets this variable in the interpreter for each application.
71
+ # The variable holds the current version number of the Tk library in the form
72
+ # major.minor. Major and minor are integers.
73
+ # The major version number increases in any Tk release that includes changes
74
+ # that are not backward compatible (i.e.
75
+ # whenever existing Tk applications and scripts may have to change to work
76
+ # with the new release).
77
+ # The minor version number increases with each new release of Tk, except that
78
+ # it resets to zero whenever the major version number changes.
79
+ def version
80
+ @version.to_s
81
+ end
82
+ end
@@ -0,0 +1,39 @@
1
+ module Tk
2
+ # Wait for variable to change or window to be destroyed
3
+ #
4
+ # This module provides blocking calls that wait for one of several things to
5
+ # happen, then return without taking any other actions.
6
+ #
7
+ # The tkwait command waits for one of several things to happen, then it
8
+ # returns without taking any other actions.
9
+ # The return value is always nil.
10
+ #
11
+ # While the methods are waiting, events are processed in the normal fashion,
12
+ # so the application will continue to respond to user interactions.
13
+ # If an event handler invokes [Wait] methods again, the nested call must
14
+ # complete before the outer call can complete.
15
+ module Wait
16
+ module_function
17
+
18
+ # Waits for the variable called +name+ to be modified.
19
+ def variable(name)
20
+ Tk.execute_only(:tkwait, :variable, name)
21
+ end
22
+
23
+ # Takes the +name+ of a window and waits for a change in its visibility
24
+ # state (as indicated by the arrival of a VisibilityNotify event).
25
+ # Typically used to wait for a newly-created window to appear on the screen
26
+ # before taking some action.
27
+ def visibility(name)
28
+ Tk.execute_only(:tkwait, :visibility, name)
29
+ end
30
+
31
+ # This method takes the name of a window as argument and waits until the
32
+ # window is destroyed.
33
+ # It is typically used to wait for a user to finish interacting with a
34
+ # dialog box before using the result of that interaction.
35
+ def window(name)
36
+ Tk.execute_only(:tkwait, :window, name)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,668 @@
1
+ module Tk
2
+ module Winfo
3
+ # @see Winfo.atom
4
+ def winfo_atom(name)
5
+ Winfo.atom(name, self)
6
+ end
7
+
8
+ # @see Winfo.atomname
9
+ def winfo_atomname(id)
10
+ Winfo.atomname(id, self)
11
+ end
12
+
13
+ # @see Winfo.cells
14
+ def winfo_cells
15
+ Winfo.cells(self)
16
+ end
17
+
18
+ # @see Winfo.children
19
+ def winfo_children
20
+ Winfo.children(self)
21
+ end
22
+
23
+ # @see Winfo.class_name
24
+ def winfo_class
25
+ Winfo.class_name(self)
26
+ end
27
+
28
+ # @see Winfo.colormapfull
29
+ def winfo_colormapfull
30
+ Winfo.colormapfull(self)
31
+ end
32
+
33
+ # @see Winfo.containing
34
+ def winfo_containing(root_x, root_y)
35
+ Winfo.containing(root_x, root_y, self)
36
+ end
37
+
38
+ # @see Winfo.depth
39
+ def winfo_depth
40
+ Winfo.depth(self)
41
+ end
42
+
43
+ # @see Winfo.exists
44
+ def winfo_exists
45
+ Winfo.exists(self)
46
+ end
47
+
48
+ # @see Winfo.fpixels
49
+ def winfo_fpixels(number)
50
+ Winfo.fpixels(self, number)
51
+ end
52
+
53
+ # @see Winfo.geometry
54
+ def winfo_geometry
55
+ Winfo.geometry(self)
56
+ end
57
+
58
+ # @see Winfo.height
59
+ def winfo_height
60
+ Winfo.height(self)
61
+ end
62
+
63
+ # @see Winfo.id
64
+ def winfo_id
65
+ Winfo.id(self)
66
+ end
67
+
68
+ # @see Winfo.interps
69
+ def winfo_interps
70
+ Winfo.interps(self)
71
+ end
72
+
73
+ # @see Winfo.ismapped
74
+ def winfo_ismapped
75
+ Winfo.ismapped(self)
76
+ end
77
+
78
+ # @see Winfo.manager
79
+ def winfo_manager
80
+ Winfo.manager(self)
81
+ end
82
+
83
+ # @see Winfo.name
84
+ def winfo_name
85
+ Winfo.name(self)
86
+ end
87
+
88
+ # @see Winfo.parent
89
+ def winfo_parent
90
+ Winfo.parent(self)
91
+ end
92
+
93
+ # @see Winfo.pathname
94
+ def winfo_pathname(id)
95
+ Winfo.pathname(id, self)
96
+ end
97
+
98
+ # @see Winfo.pixels
99
+ def winfo_pixels(number)
100
+ Winfo.pixels(self, number)
101
+ end
102
+
103
+ # @see Winfo.pointerx
104
+ def winfo_pointerx
105
+ Winfo.pointerx(self)
106
+ end
107
+
108
+ # @see Winfo.pointerxy
109
+ def winfo_pointerxy
110
+ Winfo.pointerxy(self)
111
+ end
112
+
113
+ # @see Winfo.pointery
114
+ def winfo_pointery
115
+ Winfo.pointery(self)
116
+ end
117
+
118
+ # @see Winfo.reqheight
119
+ def winfo_reqheight
120
+ Winfo.reqheight(self)
121
+ end
122
+
123
+ # @see Winfo.reqwidth
124
+ def winfo_reqwidth
125
+ Winfo.reqwidth(self)
126
+ end
127
+
128
+ # @see Winfo.rgb
129
+ def winfo_rgb(color)
130
+ Winfo.rgb(self, color)
131
+ end
132
+
133
+ # @see Winfo.rootx
134
+ def winfo_rootx
135
+ Winfo.rootx(self)
136
+ end
137
+
138
+ # @see Winfo.rooty
139
+ def winfo_rooty
140
+ Winfo.rooty(self)
141
+ end
142
+
143
+ # @see Winfo.screen
144
+ def winfo_screen
145
+ Winfo.screen(self)
146
+ end
147
+
148
+ # @see Winfo.screencells
149
+ def winfo_screencells
150
+ Winfo.screencells(self)
151
+ end
152
+
153
+ # @see Winfo.screendepth
154
+ def winfo_screendepth
155
+ Winfo.screendepth(self)
156
+ end
157
+
158
+ # @see Winfo.screenheight
159
+ def winfo_screenheight
160
+ Winfo.screenheight(self)
161
+ end
162
+
163
+ # @see Winfo.screenmmheight
164
+ def winfo_screenmmheight
165
+ Winfo.screenmmheight(self)
166
+ end
167
+
168
+ # @see Winfo.screenmmwidth
169
+ def winfo_screenmmwidth
170
+ Winfo.screenmmwidth(self)
171
+ end
172
+
173
+ # @see Winfo.screenvisual
174
+ def winfo_screenvisual
175
+ Winfo.screenvisual(self)
176
+ end
177
+
178
+ # @see Winfo.screenwidth
179
+ def winfo_screenwidth
180
+ Winfo.screenwidth(self)
181
+ end
182
+
183
+ # @see Winfo.server
184
+ def winfo_server
185
+ Winfo.server(self)
186
+ end
187
+
188
+ # @see Winfo.toplevel
189
+ def winfo_toplevel
190
+ Winfo.toplevel(self)
191
+ end
192
+
193
+ # @see Winfo.viewable
194
+ def winfo_viewable
195
+ Winfo.viewable(self)
196
+ end
197
+
198
+ # @see Winfo.visual
199
+ def winfo_visual
200
+ Winfo.visual(self)
201
+ end
202
+
203
+ # @see Winfo.visualid
204
+ def winfo_visualid
205
+ Winfo.visualid(self)
206
+ end
207
+
208
+ # @see Winfo.visualsavailable
209
+ def winfo_visualsavailable(includeids = None)
210
+ Winfo.visualsavailable(self, includeids)
211
+ end
212
+
213
+ # @see Winfo.vrootheight
214
+ def winfo_vrootheight
215
+ Winfo.vrootheight(self)
216
+ end
217
+
218
+ # @see Winfo.vrootwidth
219
+ def winfo_vrootwidth
220
+ Winfo.vrootwidth(self)
221
+ end
222
+
223
+ # @see Winfo.vrootx
224
+ def winfo_vrootx
225
+ Winfo.vrootx(self)
226
+ end
227
+
228
+ # @see Winfo.vrooty
229
+ def winfo_vrooty
230
+ Winfo.vrooty(self)
231
+ end
232
+
233
+ # @see Winfo.width
234
+ def winfo_width
235
+ Winfo.width(self)
236
+ end
237
+
238
+ # @see Winfo.x
239
+ def winfo_x
240
+ Winfo.x(self)
241
+ end
242
+
243
+ # @see Winfo.y
244
+ def winfo_y
245
+ Winfo.y(self)
246
+ end
247
+
248
+ module_function
249
+
250
+ # Returns a decimal string giving the integer identifier for the atom whose
251
+ # name is +name+.
252
+ # If no atom exists with the +name+ then a new one is created.
253
+ # If +window+ is given then the atom is looked up on the
254
+ # display of +window+; otherwise it is looked up on the display of the
255
+ # application's main window.
256
+ def atom(name, window = None)
257
+ if None == window
258
+ Tk.execute(:winfo, :atom, name)
259
+ else
260
+ Tk.execute(:winfo, :atom, '-displayof', window, name)
261
+ end
262
+ end
263
+
264
+ # Returns the textual name for the atom whose integer identifier is +id+.
265
+ # If +window+ is given then the identifier is looked up on the
266
+ # display of +window+; otherwise it is looked up on the display of the
267
+ # application's main window.
268
+ # This command is the inverse of the [atom] method.
269
+ # It generates an error if no such atom exists.
270
+ def atomname(id, window = None)
271
+ if None == window
272
+ Tk.execute(:winfo, :atomname, id).to_s
273
+ else
274
+ Tk.execute(:winfo, :atomname, '-displayof', window, id).to_s
275
+ end
276
+ end
277
+
278
+ # Returns a decimal string giving the number of cells in the color map for
279
+ # window.
280
+ def cells(window)
281
+ Tk.execute(:winfo, :cells, window)
282
+ end
283
+
284
+ # Returns a list containing the path names of all the children of window.
285
+ # Top-level windows are returned as children of their logical parents.
286
+ # The list is in stacking order, with the lowest window first, except for
287
+ # Top-level windows which are not returned in stacking order.
288
+ # Use the wm stackorder command to query the stacking order of Top-level
289
+ # windows.
290
+ def children(window)
291
+ Tk.execute(:winfo, :children, window).to_a
292
+ end
293
+
294
+ # Returns the class name for window.
295
+ #
296
+ # Note: this shadows the class method, so we call it class_name.
297
+ def class_name(window)
298
+ Tk.execute(:winfo, :class, window).to_s
299
+ end
300
+
301
+ # Returns true if the colormap for window is known to be full, false
302
+ # otherwise.
303
+ # The colormap for a window is "known" to be full if the last attempt to
304
+ # allocate a new color on that window failed and this application has not
305
+ # freed any colors in the colormap since the failed allocation.
306
+ def colormapfull(window)
307
+ Tk.execute(:winfo, :colormapfull, window).to_boolean
308
+ end
309
+
310
+ # Returns the path name for the window containing the point given by
311
+ # +root_x+ and +root_y+.
312
+ # +root_x+ and +root_y+ are specified in screen units (i.e. any form
313
+ # acceptable to Tk_GetPixels) in the coordinate system of the root
314
+ # window (if a virtual-root window manager is in use then the coordinate
315
+ # system of the virtual root window is used).
316
+ # If +window+ is given then the coordinates refer to the screen containing
317
+ # window; otherwise they refer to the screen of the application's main
318
+ # window.
319
+ # If no window in this application contains the point then nil is returned.
320
+ # In selecting the containing window, children are given higher priority
321
+ # than parents and among siblings the highest one in the stacking order is
322
+ # chosen.
323
+ def containing(root_x, root_y, window = None)
324
+ if None == window
325
+ Tk.execute(:winfo, :containing, root_x, root_y).to_s?
326
+ else
327
+ Tk.execute(:winfo, :containing, '-displayof', window, root_x, root_y).to_s?
328
+ end
329
+ end
330
+
331
+ # Returns a decimal string giving the depth of window (number of bits per
332
+ # pixel).
333
+ def depth(window)
334
+ Tk.execute(:winfo, :depth, window)
335
+ end
336
+
337
+ # Returns true if there exists a window named window, false if no such
338
+ # window exists.
339
+ def exists(window)
340
+ Tk.execute(:winfo, :exists, window).to_boolean
341
+ end
342
+
343
+ # Returns a floating-point value giving the number of pixels in window
344
+ # corresponding to the distance given by number.
345
+ # Number may be specified in any of the forms acceptable to Tk_GetScreenMM,
346
+ # such as "2.0c" or "1i".
347
+ # The return value may be fractional; for an integer value, use winfo
348
+ # pixels.
349
+ def fpixels(window, number)
350
+ Tk.execute(:winfo, :fpixels, window, number)
351
+ end
352
+
353
+ # Returns the geometry for window, in the form widthxheight+x+y.
354
+ # All dimensions are in pixels.
355
+ def geometry(window)
356
+ TkGeometry.new(Tk.execute(:winfo, :geometry, window))
357
+ end
358
+
359
+ # Returns a decimal string giving window's height in pixels.
360
+ # When a window is first created its height will be 1 pixel; the height
361
+ # will eventually be changed by a geometry manager to fulfill the window's
362
+ # needs. If you need the true height immediately after creating a widget,
363
+ # invoke update to force the geometry manager to arrange it, or use winfo
364
+ # reqheight to get the window's requested height instead of its actual
365
+ # height.
366
+ def height(window)
367
+ Tk.execute(:winfo, :height, window)
368
+ end
369
+
370
+ # Returns a hexadecimal string giving a low-level platform-specific
371
+ # identifier for window.
372
+ # On Unix platforms, this is the X window identifier.
373
+ # Under Windows, this is the Windows HWND.
374
+ # On the Macintosh the value has no meaning outside Tk.
375
+ def id(window)
376
+ Tk.execute(:winfo, :id, window).to_s
377
+ end
378
+
379
+ # Returns a list whose members are the names of all Tcl interpreters (e.g.
380
+ # all Tk-based applications) currently registered for a particular display.
381
+ # If the -displayof option is given then the return value refers to the
382
+ # display of window; otherwise it refers to the display of the
383
+ # application's main window.
384
+ def interps(window = None)
385
+ if None == window
386
+ Tk.execute(:winfo, :interps).to_a
387
+ else
388
+ Tk.execute(:winfo, :interps, '-displayof', window).to_a
389
+ end
390
+ end
391
+
392
+ # Returns true if window is currently mapped, false otherwise.
393
+ def ismapped(window)
394
+ Tk.execute(:winfo, :ismapped, window).to_boolean
395
+ end
396
+
397
+ # Returns the name of the geometry manager currently responsible for
398
+ # window, or an empty string if window is not managed by any geometry
399
+ # manager. The name is usually the name of the Tcl command for the geometry
400
+ # manager, such as pack or place.
401
+ # If the geometry manager is a widget, such as canvases or text, the name
402
+ # is the widget's class command, such as canvas.
403
+ def manager(window)
404
+ Tk.execute(:winfo, :manager, window).to_s?
405
+ end
406
+
407
+ # Returns window's name (i.e. its name within its parent, as opposed to its
408
+ # full path name).
409
+ # `Winfo.name('.')` will return the name of the application.
410
+ def name(window)
411
+ Tk.execute(:winfo, :name, window).to_s
412
+ end
413
+
414
+ # Returns the path name of +window+'s parent, or nil if +window+ is the main
415
+ # window of the application.
416
+ def parent(window)
417
+ Tk.execute(:winfo, :parent, window).to_s?
418
+ end
419
+
420
+ # Returns the path name of the window whose X identifier is +id+.
421
+ # +id+ must be a decimal, hexadecimal, or octal integer and must correspond
422
+ # to a window in the invoking application.
423
+ # If +window+ is given then the identifier is looked up on
424
+ # the display of window; otherwise it is looked up on the display of the
425
+ # application's main window.
426
+ def pathname(id, window = None)
427
+ if None == window
428
+ Tk.execute(:winfo, :pathname, id).to_s
429
+ else
430
+ Tk.execute(:winfo, :pathname, '-displayo', window, id).to_s
431
+ end
432
+ end
433
+
434
+ # Returns the number of pixels in window corresponding to the distance
435
+ # given by number.
436
+ # Number may be specified in any of the forms acceptable to Tk_GetPixels,
437
+ # such as “2.0c” or “1i”.
438
+ # The result is rounded to the nearest integer value; for a fractional
439
+ # result, use winfo fpixels.
440
+ def pixels(window, number)
441
+ Tk.execute(:winfo, :pixels, window, number).to_i
442
+ end
443
+
444
+ # If the mouse pointer is on the same screen as window, returns the
445
+ # pointer's x coordinate, measured in pixels in the screen's root window.
446
+ # If a virtual root window is in use on the screen, the position is
447
+ # measured in the virtual root.
448
+ # If the mouse pointer is not on the same screen as window then -1 is
449
+ # returned.
450
+ def pointerx(window)
451
+ Tk.execute(:winfo, :pointerx, window).to_i
452
+ end
453
+
454
+ # If the mouse pointer is on the same screen as window, returns a list with
455
+ # two elements, which are the pointer's x and y coordinates measured in
456
+ # pixels in the screen's root window.
457
+ # If a virtual root window is in use on the screen, the position is
458
+ # computed in the virtual root.
459
+ # If the mouse pointer is not on the same screen as window then both of the
460
+ # returned coordinates are -1.
461
+ def pointerxy(window)
462
+ Tk.execute(:winfo, :pointerxy, window).to_a(&:to_i)
463
+ end
464
+
465
+ # If the mouse pointer is on the same screen as window, returns the
466
+ # pointer's y coordinate, measured in pixels in the screen's root window.
467
+ # If a virtual root window is in use on the screen, the position is
468
+ # computed in the virtual root.
469
+ # If the mouse pointer is not on the same screen as window then -1 is
470
+ # returned.
471
+ def pointery(window)
472
+ Tk.execute(:winfo, :pointery, window).to_i
473
+ end
474
+
475
+ # Returns a decimal string giving window's requested height, in pixels.
476
+ # This is the value used by window's geometry manager to compute its
477
+ # geometry.
478
+ def reqheight(window)
479
+ Tk.execute(:winfo, :reqheight, window)
480
+ end
481
+
482
+ # Returns a decimal string giving window's requested width, in pixels.
483
+ # This is the value used by window's geometry manager to compute its
484
+ # geometry.
485
+ def reqwidth(window)
486
+ Tk.execute(:winfo, :reqwidth, window)
487
+ end
488
+
489
+ # Returns a list containing three decimal values in the range 0 to 65535,
490
+ # which are the red, green, and blue intensities that correspond to color
491
+ # in the window given by window.
492
+ # Color may be specified in any of the forms acceptable for a color option.
493
+ def rgb(window, color)
494
+ Tk.execute(:winfo, :rgb, window, color).to_a(&:to_i)
495
+ end
496
+
497
+ # Returns a decimal string giving the x-coordinate, in the root window of
498
+ # the screen, of the upper-left corner of window's border (or window if it
499
+ # has no border).
500
+ def rootx(window)
501
+ Tk.execute(:winfo, :rootx, window)
502
+ end
503
+
504
+ # Returns a decimal string giving the y-coordinate, in the root window of
505
+ # the screen, of the upper-left corner of window's border (or window if it
506
+ # has no border).
507
+ def rooty(window)
508
+ Tk.execute(:winfo, :rooty, window)
509
+ end
510
+
511
+ # Returns the name of the screen associated with window, in the form
512
+ # displayName.screenIndex.
513
+ def screen(window)
514
+ Tk.execute(:winfo, :screen, window)
515
+ end
516
+
517
+ # Returns a decimal string giving the number of cells in the default color
518
+ # map for window's screen.
519
+ def screencells(window)
520
+ Tk.execute(:winfo, :screencells, window)
521
+ end
522
+
523
+ # Returns a decimal string giving the depth of the root window of window's
524
+ # screen (number of bits per pixel).
525
+ def screendepth(window)
526
+ Tk.execute(:winfo, :screendepth, window)
527
+ end
528
+
529
+ # Returns a decimal string giving the height of window's screen, in pixels.
530
+ def screenheight(window)
531
+ Tk.execute(:winfo, :screenheight, window)
532
+ end
533
+
534
+ # Returns a decimal string giving the height of window's screen, in
535
+ # millimeters.
536
+ def screenmmheight(window)
537
+ Tk.execute(:winfo, :screenmmheight, window)
538
+ end
539
+
540
+ # Returns a decimal string giving the width of window's screen, in
541
+ # millimeters.
542
+ def screenmmwidth(window)
543
+ Tk.execute(:winfo, :screenmmwidth, window)
544
+ end
545
+
546
+ # Returns one of the following strings to indicate the default visual class
547
+ # for window's screen: directcolor, grayscale, pseudocolor, staticcolor,
548
+ # staticgray, or truecolor.
549
+ def screenvisual(window)
550
+ Tk.execute(:winfo, :screenvisual, window).to_sym
551
+ end
552
+
553
+ # Returns a decimal string giving the width of window's screen, in pixels.
554
+ def screenwidth(window)
555
+ Tk.execute(:winfo, :screenwidth, window)
556
+ end
557
+
558
+ # Returns a string containing information about the server for window's
559
+ # display. The exact format of this string may vary from platform to
560
+ # platform. For X servers the string has the form:
561
+ # "XmajorRminor vendor vendorVersion"
562
+ # where major and minor are the version and revision numbers provided by the
563
+ # server (e.g., X11R5), vendor is the name of the vendor for the server, and
564
+ # vendorRelease is an integer release number provided by the server.
565
+ def server(window)
566
+ Tk.execute(:winfo, :server, window)
567
+ end
568
+
569
+ # Returns the path name of the top-of-hierarchy window containing window.
570
+ # In standard Tk this will always be a toplevel widget, but extensions may
571
+ # create other kinds of top-of-hierarchy widgets.
572
+ def toplevel(window)
573
+ Tk.execute(:winfo, :toplevel, window).to_s
574
+ end
575
+
576
+ # Returns true if window and all of its ancestors up through the nearest
577
+ # toplevel window are mapped.
578
+ # Returns false if any of these windows are not mapped.
579
+ def viewable(window)
580
+ Tk.execute(:winfo, :viewable, window).to_boolean
581
+ end
582
+
583
+ # Returns one of the following strings to indicate the visual class for
584
+ # window:
585
+ # :directcolor, :grayscale, :pseudocolor, :staticcolor, :staticgray,
586
+ # :truecolor
587
+ def visual(window)
588
+ Tk.execute(:winfo, :visual, window).to_sym
589
+ end
590
+
591
+ # Returns the X identifier for the visual for window.
592
+ def visualid(window)
593
+ Tk.execute(:winfo, :visualid, window).to_s
594
+ end
595
+
596
+ # Returns a list whose elements describe the visuals available for window's
597
+ # screen. Each element consists of a visual class followed by an integer
598
+ # depth. The class has the same form as returned by winfo visual.
599
+ # The depth gives the number of bits per pixel in the visual.
600
+ # In addition, if the includeids argument is provided, then the depth is
601
+ # followed by the X identifier for the visual.
602
+ def visualsavailable(window, includeids = None)
603
+ if None == includeids
604
+ list = Tk.execute(:winfo, :visualsavailable, window).to_a
605
+ list.uniq.map{|string|
606
+ klass, depth = string.split
607
+ [klass, depth.to_i]
608
+ }
609
+ else
610
+ list = Tk.execute(:winfo, :visualsavailable, window, :includeids).to_a
611
+ list.uniq.map{|string|
612
+ klass, depth, id = string.split
613
+ [klass, depth.to_i, id]
614
+ }
615
+ end
616
+ end
617
+
618
+ # Returns the height of the virtual root window associated with window if
619
+ # there is one; otherwise returns the height of window's screen.
620
+ def vrootheight(window)
621
+ Tk.execute(:winfo, :vrootheight, window)
622
+ end
623
+
624
+ # Returns the width of the virtual root window associated with window if
625
+ # there is one; otherwise returns the width of window's screen.
626
+ def vrootwidth(window)
627
+ Tk.execute(:winfo, :vrootwidth, window)
628
+ end
629
+
630
+ # Returns the x-offset of the virtual root window associated with window,
631
+ # relative to the root window of its screen.
632
+ # This is normally either zero or negative.
633
+ # Returns 0 if there is no virtual root window for window.
634
+ def vrootx(window)
635
+ Tk.execute(:winfo, :vrootx, window)
636
+ end
637
+
638
+ # Returns the y-offset of the virtual root window associated with window,
639
+ # relative to the root window of its screen.
640
+ # This is normally either zero or negative.
641
+ # Returns 0 if there is no virtual root window for window.
642
+ def vrooty(window)
643
+ Tk.execute(:winfo, :vrooty, window)
644
+ end
645
+
646
+ # Returns a decimal string giving window's width in pixels.
647
+ # When a window is first created its width will be 1 pixel; the width will
648
+ # eventually be changed by a geometry manager to fulfill the window's
649
+ # needs. If you need the true width immediately after creating a widget,
650
+ # invoke update to force the geometry manager to arrange it, or use winfo
651
+ # reqwidth to get the window's requested width instead of its actual width.
652
+ def width(window)
653
+ Tk.execute(:winfo, :width, window)
654
+ end
655
+
656
+ # Returns a decimal string giving the x-coordinate, in window's parent, of
657
+ # the upper-left corner of window's border (or window if it has no border).
658
+ def x(window)
659
+ Tk.execute(:winfo, :x, window)
660
+ end
661
+
662
+ # Returns a decimal string giving the y-coordinate, in window's parent, of
663
+ # the upper-left corner of window's border (or window if it has no border).
664
+ def y(window)
665
+ Tk.execute(:winfo, :y, window)
666
+ end
667
+ end
668
+ end