ffi-tk 2009.11.29

Sign up to get free protection for your applications and to get access to all the features.
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,1025 @@
1
+ module Tk
2
+ # Communicate with window manager
3
+ # The wm command is used to interact with window managers in order to control
4
+ # such things as the title for a window, its geometry, or the increments in
5
+ # terms of which it may be resized.
6
+ # All of the methods expect at least one additional argument, window, which
7
+ # must be the path name of a top-level window.
8
+ module WM
9
+ # @see WM::aspect
10
+ def wm_aspect
11
+ WM.aspect(self)
12
+ end
13
+
14
+ # @see WM::aspect
15
+ def wm_aspect=(aspects)
16
+ WM.aspect(self, *[aspects].flatten)
17
+ end
18
+
19
+ # @see WM::attributes
20
+ def wm_attributes(options = None)
21
+ WM.attributes(self, options)
22
+ end
23
+
24
+ # @see WM::client
25
+ def wm_client
26
+ WM.client(self)
27
+ end
28
+
29
+ def wm_client=(name)
30
+ WM.client(self, name)
31
+ end
32
+
33
+ # @see WM::colormapwindows
34
+ def wm_colormapwindows
35
+ WM.colormapwindows(self)
36
+ end
37
+
38
+ def wm_colormapwindows=(windows)
39
+ WM.colormapwindows(self, *windows)
40
+ end
41
+
42
+ # @see WM::command
43
+ def wm_command
44
+ WM.command(self)
45
+ end
46
+
47
+ # @see WM::command
48
+ def wm_command=(value)
49
+ WM.command(self, value)
50
+ end
51
+
52
+ # @see WM::deiconify
53
+ def wm_deiconify
54
+ WM.deiconify(self)
55
+ end
56
+
57
+ # @see WM::focusmodel
58
+ def wm_focusmodel
59
+ WM.focusmodel(self)
60
+ end
61
+
62
+ # @see WM::focusmodel
63
+ def wm_focusmodel=(model)
64
+ WM.focusmodel(self, model)
65
+ end
66
+
67
+ # @see WM::forget
68
+ def wm_forget
69
+ WM.forget(self)
70
+ end
71
+
72
+ # @see WM::frame
73
+ def wm_frame
74
+ WM.frame(self)
75
+ end
76
+
77
+ # @see WM::geometry
78
+ def wm_geometry
79
+ WM.geometry(self)
80
+ end
81
+
82
+ # @see WM::geometry
83
+ def wm_geometry=(new_geometry)
84
+ WM.geometry(self, new_geometry)
85
+ end
86
+
87
+ # @see WM::grid
88
+ def wm_grid
89
+ WM.grid(self)
90
+ end
91
+
92
+ def wm_grid=(grid_info)
93
+ WM.grid(self, *[grid_info].flatten)
94
+ end
95
+
96
+ # @see WM::group
97
+ def wm_group
98
+ WM.group(self)
99
+ end
100
+
101
+ # @see WM::group
102
+ def wm_group=(pathname)
103
+ WM.group(self, pathname)
104
+ end
105
+
106
+ # @see WM::iconbitmap
107
+ def wm_iconbitmap
108
+ WM.iconbitmap(self)
109
+ end
110
+
111
+ # @see WM::iconbitmap
112
+ def wm_iconbitmap=(bitmap)
113
+ WM.iconbitmap(self, bitmap)
114
+ end
115
+
116
+ # @see WM::iconbitmap_default
117
+ def wm_iconbitmap_default
118
+ WM.iconbitmap_default(self)
119
+ end
120
+
121
+ # @see WM::iconbitmap_default
122
+ def wm_iconbitmap_default=(image)
123
+ WM.iconbitmap_default(self, image)
124
+ end
125
+
126
+ # @see WM::iconify
127
+ def wm_iconify
128
+ WM.iconify(self)
129
+ end
130
+
131
+ # @see WM::iconmask
132
+ def wm_iconmask
133
+ WM.iconmask(self)
134
+ end
135
+
136
+ # @see WM::iconmask
137
+ def wm_iconmask=(bitmap)
138
+ WM.iconmask(self, bitmap)
139
+ end
140
+
141
+ # @see WM::iconname
142
+ def wm_iconname(new_name = None)
143
+ WM.iconname(self, new_name)
144
+ end
145
+
146
+ # @see WM::iconname
147
+ def wm_iconname=(new_name)
148
+ WM.iconname(self, new_name)
149
+ end
150
+
151
+ # @see WM::iconphoto
152
+ def wm_iconphoto(image, *images)
153
+ WM.iconphoto(self, image, *images)
154
+ end
155
+
156
+ # @see WM::iconphoto
157
+ def wm_iconphoto=(*images)
158
+ WM.iconphoto(self, *images)
159
+ end
160
+
161
+ # @see WM::iconphoto_default
162
+ def wm_iconphoto_default(image, *images)
163
+ WM.iconphoto_default(self, image, *images)
164
+ end
165
+
166
+ # @see WM::iconphoto_default
167
+ def wm_iconphoto_default=(*images)
168
+ WM.iconphoto_default(self, *images)
169
+ end
170
+
171
+ # @see WM::iconposition
172
+ def wm_iconposition(y = None, x = None)
173
+ WM.iconposition(self, y, x)
174
+ end
175
+
176
+ # @see WM::iconposition
177
+ def wm_iconposition=(yx)
178
+ WM.iconposition(self, *yx)
179
+ end
180
+
181
+ # @see WM::iconwindow
182
+ def wm_iconwindow
183
+ WM.iconwindow(self)
184
+ end
185
+
186
+ # @see WM::iconwindow
187
+ def wm_iconwindow=(pathname)
188
+ WM.iconwindow(self, pathname)
189
+ end
190
+
191
+ # @see WM::manage
192
+ def wm_manage
193
+ WM.manage(self)
194
+ end
195
+
196
+ # @see WM::maxsize
197
+ def wm_maxsize(width = None, height = None)
198
+ WM.maxsize(self, width, height)
199
+ end
200
+
201
+ # @see WM::minsize
202
+ def wm_minsize(width = None, height = None)
203
+ WM.minsize(self, width, height)
204
+ end
205
+
206
+ # @see WM::overrideredirect
207
+ def wm_overrideredirect
208
+ WM.overrideredirect(self)
209
+ end
210
+
211
+ # @see WM::overrideredirect
212
+ def wm_overrideredirect=(boolean)
213
+ WM.overrideredirect(self, boolean)
214
+ end
215
+
216
+ # @see WM::positionfrom
217
+ def wm_positionfrom
218
+ WM.positionfrom(self)
219
+ end
220
+
221
+ # @see WM::positionfrom
222
+ def wm_positionfrom=(who)
223
+ WM.positionfrom(self, who)
224
+ end
225
+
226
+ # @see WM::protocol
227
+ def wm_protocol(name = None, command = None, &block)
228
+ WM.protocol(self, name, command, &block)
229
+ end
230
+
231
+ # @see WM::resizable
232
+ def wm_resizable(width = None, height = None)
233
+ WM.resizable(self, width, height)
234
+ end
235
+
236
+ # @see WM::sizefrom
237
+ def wm_sizefrom
238
+ WM.sizefrom(self)
239
+ end
240
+
241
+ # @see WM::sizefrom
242
+ def wm_sizefrom=(who)
243
+ WM.sizefrom(self, who)
244
+ end
245
+
246
+ # @see WM::stackorder
247
+ def wm_stackorder(order = None, other_window = None)
248
+ WM.stackorder(self, order, other_window)
249
+ end
250
+
251
+ # @see WM::state
252
+ def wm_state
253
+ WM.state(self)
254
+ end
255
+
256
+ # @see WM::state
257
+ def wm_state=(new_state)
258
+ WM.state(self, new_state)
259
+ end
260
+
261
+ # @see WM::title
262
+ def wm_title
263
+ WM.title(self)
264
+ end
265
+
266
+ def wm_title=(string)
267
+ WM.title(self, string)
268
+ end
269
+
270
+ # @see WM::transient
271
+ def wm_transient
272
+ WM.transient(self)
273
+ end
274
+
275
+ # @see WM::transient
276
+ def wm_transient=(master)
277
+ WM.transient(self, master)
278
+ end
279
+
280
+ # @see WM::withdraw
281
+ def wm_withdraw
282
+ WM.withdraw(self)
283
+ end
284
+
285
+ module_function
286
+
287
+ # If minNumer, minDenom, maxNumer, and maxDenom are all specified, then they
288
+ # will be passed to the window manager and the window manager should use
289
+ # them to enforce a range of acceptable aspect ratios for window.
290
+ # The aspect ratio of window (width/length) will be constrained to lie
291
+ # between minNumer/minDenom and maxNumer/maxDenom.
292
+ # If minNumer etc. are all specified as empty strings, then any existing
293
+ # aspect ratio restrictions are removed.
294
+ # If minNumer etc. are specified, then the command returns nil.
295
+ # Otherwise, it returns a Tcl list containing four elements, which are the
296
+ # current values of minNumer, minDenom, maxNumer, and maxDenom (if no aspect
297
+ # restrictions are in effect, then nil is returned).
298
+ def aspect(window, min_numer = None, min_denom = None, max_numer = None, max_denom = None)
299
+ if min_numer == None
300
+ result = Tk.execute(:wm, :aspect, window)
301
+ result.to_s == '' ? nil : result.to_a(&:to_i)
302
+ elsif min_numer.nil?
303
+ Tk.execute_only(:wm, :aspect, window, '', '', '', '')
304
+ else
305
+ result = Tk.execute_only(:wm, :aspect, window,
306
+ min_numer, min_denom, max_numer, max_denom)
307
+ if result.to_s == ''
308
+ nil
309
+ else
310
+ result
311
+ end
312
+ end
313
+ end
314
+
315
+ # This methods returns or sets platform specific attributes associated with
316
+ # a window.
317
+ # The first form returns a list of the platform specific flags and their
318
+ # values. The second form returns the value for the specific option.
319
+ # The third form sets one or more of the values.
320
+ # The options are as follows:
321
+ #
322
+ # All platforms support the following attributes (though X11 users should
323
+ # see the notes below):
324
+ #
325
+ # :fullscreen
326
+ # Places the window in a mode that takes up the entire screen, has no
327
+ # borders, and covers the general use area (i.e.
328
+ # Start menu and taskbar on Windows, dock and menubar on OSX, general
329
+ # window decorations on X11).
330
+ #
331
+ # :topmost
332
+ # Specifies whether this is a topmost window (displays above all other
333
+ # windows).
334
+ #
335
+ # On Windows, the following attributes may be set.
336
+ #
337
+ # :alpha
338
+ # Specifies the alpha transparency level of the toplevel.
339
+ # It accepts a value from 0.0 (fully transparent) to 1.0 (opaque).
340
+ # Values outside that range will be constrained.
341
+ # This is supported on Windows 2000/XP+.
342
+ # Where not supported, the :alpha value remains at 1.0.
343
+ #
344
+ # :disabled
345
+ # Specifies whether the window is in a disabled state.
346
+ #
347
+ # :toolwindow
348
+ # Specifies a toolwindow style window (as defined in the MSDN).
349
+ #
350
+ # :transparentcolor
351
+ # Specifies the transparent color index of the toplevel.
352
+ # It takes any color value accepted by Tk_GetColor.
353
+ # If the empty string is specified (default), no transparent color is
354
+ # used. This is supported on Windows 2000/XP+.
355
+ # Where not supported, the :transparentcolor value remains at {}.
356
+ #
357
+ # On Mac OS X, the following attributes may be set.
358
+ #
359
+ # :alpha
360
+ # Specifies the alpha transparency level of the window.
361
+ # It accepts a value from 0.0 (fully transparent) to 1.0 (opaque),
362
+ # values outside that range will be constrained.
363
+ #
364
+ # :modified
365
+ # Specifies the modification state of the window (determines whether the
366
+ # window close widget contains the modification indicator and whether
367
+ # the proxy icon is draggable).
368
+ #
369
+ # :notify
370
+ # Specifies process notification state (bouncing of the application
371
+ # dock icon).
372
+ #
373
+ # :titlepath
374
+ # Specifies the path of the file referenced as the window proxy icon
375
+ # (which can be dragged and dropped in lieu of the file's finder icon).
376
+ #
377
+ # :transparent
378
+ # Makes the window content area transparent and turns off the window
379
+ # shadow. For the transparency to be effecive, the toplevel background
380
+ # needs to be set to a color with some alpha, e.g.
381
+ # ?systemTransparent?.
382
+ #
383
+ # On X11, the following attributes may be set. These are not supported by all window managers, and will have no effect under older WMs.
384
+ #
385
+ # :zoomed
386
+ # Requests that the window should be maximized.
387
+ # This is the same as wm state zoomed on Windows and Mac OS X.
388
+ #
389
+ # On X11, changes to window attributes are performed asynchronously.
390
+ # Querying the value of an attribute returns the current state, which will
391
+ # not be the same as the value most recently set if the window manager has
392
+ # not yet processed the request or if it does not support the attribute.
393
+ def attributes(window, options = None)
394
+ if options == None
395
+ result = Tk.execute(:wm, :attributes, window)
396
+ result.tcl_options_to_hash(WM_ATTRIBUTES_HINTS)
397
+ elsif options.respond_to?(:to_tcl_options)
398
+ Tk.execute_only(:wm, :attributes, window, options.to_tcl_options)
399
+ elsif options.respond_to?(:to_tcl_option)
400
+ option = options.to_tcl_option
401
+ value = Tk.execute(:wm, :attributes, window, options.to_tcl_option)
402
+ value.tcl_to_ruby(option, WM_ATTRIBUTES_HINTS)
403
+ else
404
+ raise ArgumentError
405
+ end
406
+ end
407
+
408
+ WM_ATTRIBUTES_HINTS = {
409
+ alpha: :float,
410
+ topmost: :boolean,
411
+ zoomed: :boolean,
412
+ fullscreen: :boolean,
413
+ }
414
+
415
+ # If name is specified, this command stores name (which should be the name
416
+ # of the host on which the application is executing) in window's
417
+ # WM_CLIENT_MACHINE property for use by the window manager or session
418
+ # manager. The command returns nil in this case.
419
+ # If name is not specified, the command returns the last name set in a wm
420
+ # client command for window.
421
+ # If name is specified as nil, the command deletes the
422
+ # WM_CLIENT_MACHINE property from window.
423
+ def client(window, name = None)
424
+ if name == None
425
+ Tk.execute(:wm, :client, window).to_s?
426
+ else
427
+ Tk.execute_only(:wm, :client, window, name)
428
+ end
429
+ end
430
+
431
+ # This command is used to manipulate the WM_COLORMAP_WINDOWS property, which
432
+ # provides information to the window managers about windows that have
433
+ # private colormaps.
434
+ #
435
+ # If windowList is not specified, the command returns a list whose elements
436
+ # are the names of the windows in the WM_COLORMAP_WINDOWS property.
437
+ # If windowList is specified, it consists of a list of window path names;
438
+ # the command overwrites the WM_COLORMAP_WINDOWS property with the given
439
+ # windows and returns nil.
440
+ # The WM_COLORMAP_WINDOWS property should normally contain a list of the
441
+ # internal windows within window whose colormaps differ from their parents.
442
+ #
443
+ # The order of the windows in the property indicates a priority order: the
444
+ # window manager will attempt to install as many colormaps as possible from
445
+ # the head of this list when window gets the colormap focus.
446
+ # If window is not included among the windows in windowList, Tk implicitly
447
+ # adds it at the end of the WM_COLORMAP_WINDOWS property, so that its
448
+ # colormap is lowest in priority.
449
+ # If wm colormapwindows is not invoked, Tk will automatically set the
450
+ # property for each top-level window to all the internal windows whose
451
+ # colormaps differ from their parents, followed by the top-level itself; the
452
+ # order of the internal windows is undefined.
453
+ # See the ICCCM documentation for more information on the
454
+ # WM_COLORMAP_WINDOWS property.
455
+ def colormapwindows(window, *windows)
456
+ if windows.empty?
457
+ Tk.execute(:wm, :colormapwindows, window).to_a
458
+ else
459
+ Tk.execute_only(:wm, :colormapwindows, window, *windows)
460
+ end
461
+ end
462
+
463
+ # If value is specified, this command stores value in window's WM_COMMAND
464
+ # property for use by the window manager or session manager and returns an
465
+ # empty string.
466
+ # Value must have proper list structure; the elements should contain the
467
+ # words of the command used to invoke the application.
468
+ # If value is not specified then the command returns the last value set in a
469
+ # wm command command for window.
470
+ # If value is specified as nil, the command deletes the
471
+ # WM_COMMAND property from window.
472
+ def command(window, value = None)
473
+ if value == None
474
+ Tk.execute(:wm, :command, window).to_a
475
+ else
476
+ Tk.execute_only(:wm, :command, window, value)
477
+ end
478
+ end
479
+
480
+ # Arrange for window to be displayed in normal (non-iconified) form.
481
+ # This is done by mapping the window.
482
+ # If the window has never been mapped then this command will not map the
483
+ # window, but it will ensure that when the window is first mapped it will be
484
+ # displayed in de-iconified form.
485
+ # On Windows, a deiconified window will also be raised and be given the
486
+ # focus (made the active window).
487
+ def deiconify(window)
488
+ Tk.execute_only(:wm, :deiconify, window)
489
+ end
490
+
491
+ # If active or passive is supplied as an optional argument to the command,
492
+ # then it specifies the focus model for window.
493
+ # In this case the command returns nil.
494
+ # If no additional argument is supplied, then the command returns the
495
+ # current focus model for window.
496
+ #
497
+ # An active focus model means that window will claim the input focus for
498
+ # itself or its descendants, even at times when the focus is currently in
499
+ # some other application.
500
+ # Passive means that win? dow will never claim the focus for itself: the
501
+ # window manager should give the focus to window at appropriate times.
502
+ # However, once the focus has been given to window or one of its descen?
503
+ # dants, the application may re-assign the focus among window's descendants.
504
+ # The focus model defaults to passive, and Tk's focus command assumes a
505
+ # passive model of focusing.
506
+ def focusmodel(window, model = None)
507
+ if model == None
508
+ Tk.execute(:wm, :focusmodel, window).to_sym
509
+ else
510
+ Tk.execute_only(:wm, :focusmodel, window, model)
511
+ end
512
+ end
513
+
514
+ # The window will be unmapped from the screen and will no longer be managed
515
+ # by wm.
516
+ # Windows created with the toplevel command will be treated like frame
517
+ # windows once they are no longer managed by wm, however, the :menu
518
+ # configuration will be remembered and the menus will return once the widget
519
+ # is managed again.
520
+ def forget(window)
521
+ Tk.execute(:wm, :forget, window)
522
+ end
523
+
524
+ # If window has been reparented by the window manager into a decorative
525
+ # frame, the command returns the platform specific window identifier for the
526
+ # outermost frame that contains window (the window whose parent is the
527
+ # root or virtual root).
528
+ # If window has not been reparented by the window manager then the command
529
+ # returns the platform specific window identifier for window.
530
+ def frame(window)
531
+ Tk.execute(:wm, :frame, window).to_s
532
+ end
533
+
534
+ # If newGeometry is specified, then the geometry of window is changed and an
535
+ # empty string is returned.
536
+ # Otherwise the current geometry for window is returned (this is the most
537
+ # recent geometry specified either by manual resizing or in a wm geometry
538
+ # command). NewGeometry has the form =widthxheight?x?y, where any of =,
539
+ # widthxheight, or ?x?y may be omitted.
540
+ # Width and height are posi? tive integers specifying the desired dimensions
541
+ # of window.
542
+ # If window is gridded (see GRIDDED GEOMETRY MANAGEMENT below) then the
543
+ # dimensions are specified in grid units; otherwise they are specified in
544
+ # pixel units.
545
+ #
546
+ # X and y specify the desired location of window on the screen, in pixels.
547
+ # If x is preceded by +, it specifies the number of pixels between the left
548
+ # edge of the screen and the left edge of win? dow's border; if preceded by
549
+ # - then x specifies the number of pixels between the right edge of the
550
+ # screen and the right edge of window's border.
551
+ # If y is preceded by + then it specifies the number of pixels between the
552
+ # top of the screen and the top of window's border; if y is preceded by -
553
+ # then it specifies the number of pixels between the bottom of window's
554
+ # border and the bot? tom of the screen.
555
+ #
556
+ # If newGeometry is specified as nil then any existing
557
+ # user-specified geometry for window is cancelled, and the window will
558
+ # revert to the size requested internally by its widgets.
559
+ def geometry(window, new_geometry = None)
560
+ if new_geometry == None
561
+ TkGeometry.new(Tk.execute(:wm, :geometry, window))
562
+ else
563
+ Tk.execute_only(:wm, :geometry, window, new_geometry)
564
+ end
565
+ end
566
+
567
+ # This command indicates that window is to be managed as a gridded window.
568
+ # It also specifies the relationship between grid units and pixel units.
569
+ # BaseWidth and baseHeight specify the number of grid units corresponding to
570
+ # the pixel dimensions requested internally by window using
571
+ # Tk_GeometryRequest. WidthInc and heightInc specify the number of pixels in
572
+ # each horizontal and vertical grid unit.
573
+ # These four values determine a range of acceptable sizes for window,
574
+ # corresponding to grid-based widths and heights that are non-negative
575
+ # integers. Tk will pass this information to the window manager; during
576
+ # manual resizing, the window manager will restrict the window's size to one
577
+ # of these acceptable sizes.
578
+ #
579
+ # Furthermore, during manual resizing the window manager will display the
580
+ # window's current size in terms of grid units rather than pixels.
581
+ # If baseWidth etc.
582
+ # are all specified as empty strings, then window will no longer be managed
583
+ # as a gridded window.
584
+ # If baseWidth etc.
585
+ # are specified then the return value is nil.
586
+ #
587
+ # Otherwise the return value is a Tcl list containing four elements
588
+ # corresponding to the current baseWidth, baseHeight, widthInc, and
589
+ # heightInc; if window is not currently gridded, then nil is
590
+ # returned.
591
+ #
592
+ # Note: this command should not be needed very often, since the Tk_SetGrid
593
+ # library procedure and the setGrid option provide easier access to the same
594
+ # functionality.
595
+ def grid(window, base_width = None, base_height = None, width_inc = None, height_inc = None)
596
+ if base_width == None
597
+ Tk.execute(:wm, :grid, window).to_a?(&:to_i)
598
+ else
599
+ Tk.execute_only(:wm, :grid, window, base_width, base_height, width_inc, height_inc)
600
+ end
601
+ end
602
+
603
+ # If pathName is specified, it gives the path name for the leader of a group
604
+ # of related windows.
605
+ # The window manager may use this information, for example, to unmap all of
606
+ # the windows in a group when the group's leader is iconified.
607
+ # PathName may be specified as nil to remove window from any
608
+ # group association.
609
+ # If pathName is specified then the command returns nil;
610
+ # otherwise it returns the path name of window's current group leader, or nil
611
+ # if window is not part of any group.
612
+ def group(window, pathname = None)
613
+ if None == pathname
614
+ Tk.execute(:wm, :group, window).to_s?
615
+ else
616
+ Tk.execute_only(:wm, :group, window, pathname)
617
+ end
618
+ end
619
+
620
+ #wm iconbitmap window ?bitmap?
621
+ # If bitmap is specified, then it names a bitmap in the standard forms
622
+ # accepted by Tk (see the Tk_GetBitmap manual entry for details).
623
+ # This bitmap is passed to the window manager to be dis? played in window's
624
+ # icon, and the command returns nil.
625
+ # If nil is specified for bitmap, then any current icon bitmap
626
+ # is cancelled for window.
627
+ # If bitmap is specified then the command returns nil.
628
+ # Otherwise it returns the name of the current icon bitmap associated with
629
+ # window, or nil if window has no icon bitmap.
630
+ # On the Windows operating system, an additional flag is supported:
631
+ def iconbitmap(window, bitmap = None)
632
+ if None == bitmap
633
+ Tk.execute(:wm, :iconbitmap, window).to_s?
634
+ else
635
+ Tk.execute_only(:wm, :iconbitmap, window, bitmap)
636
+ end
637
+ end
638
+
639
+ # If the -default flag is given, the icon is applied to all toplevel windows
640
+ # (existing and future) to which no other specific icon has yet been
641
+ # applied.
642
+ # In addition to bitmap image types, a full path specification to any file
643
+ # which contains a valid Windows icon is also accepted (usually .ico or .icr
644
+ # files), or any file for which the shell has assigned an icon.
645
+ # Tcl will first test if the file contains an icon, then if it has an
646
+ # assigned icon, and finally, if that fails, test for a bitmap.
647
+ def iconbitmap_default(window, image = None)
648
+ Tk.execute(:wm, :iconbitmap, window, '-default', image)
649
+ end
650
+
651
+ # Arrange for window to be iconified.
652
+ # It window has not yet been mapped for the first time, this command will
653
+ # arrange for it to appear in the iconified state when it is eventually
654
+ # mapped.
655
+ def iconify(window)
656
+ Tk.execute_only(:wm, :iconify, window)
657
+ end
658
+
659
+ # If bitmap is specified, then it names a bitmap in the standard forms
660
+ # accepted by Tk (see the Tk_GetBitmap manual entry for details).
661
+ # This bitmap is passed to the window manager to be used as a mask in
662
+ # conjunction with the iconbitmap option: where the mask has zeroes no icon
663
+ # will be displayed; where it has ones, the bits from the icon bitmap will
664
+ # be displayed.
665
+ # If nil is specified for bitmap then any current icon mask is
666
+ # cancelled for window (this is equivalent to specifying a bitmap of all
667
+ # ones). If bitmap is specified then the command returns nil.
668
+ # Otherwise it returns the name of the current icon mask associated with
669
+ # window, or nil if no mask is in effect.
670
+ def iconmask(window, bitmap = None)
671
+ if None == bitmap
672
+ Tk.execute(:wm, :iconmask, window).to_s?
673
+ else
674
+ Tk.execute_only(:wm, :iconmask, window, bitmap)
675
+ end
676
+ end
677
+
678
+ # If newName is specified, then it is passed to the window manager; the
679
+ # window manager should display newName inside the icon associated with
680
+ # window. In this case nil is returned as result.
681
+ # If newName is not specified then the command returns the current icon name
682
+ # for window, or nil if no icon name has been specified (in this
683
+ # case the window manager will normally display the window's title, as
684
+ # specified with the wm title command).
685
+ def iconname(window, new_name = None)
686
+ if None == new_name
687
+ Tk.execute(:wm, :iconname, window).to_s?
688
+ else
689
+ Tk.execute_only(:wm, :iconname, window, new_name)
690
+ end
691
+ end
692
+
693
+ # Sets the titlebar icon for window based on the named photo images.
694
+ #
695
+ # The data in the images is taken as a snapshot at the time of invocation.
696
+ # If the images are later changed, this is not reflected to the titlebar
697
+ # icons. Multiple images are accepted to allow different images sizes (e.g.,
698
+ # 16x16 and 32x32) to be provided.
699
+ # The window manager may scale provided icons to an appropriate size.
700
+ #
701
+ # On Windows, the images are packed into a Windows icon structure.
702
+ # This will override an ico specified to wm iconbitmap, and vice versa.
703
+ #
704
+ # On X, the images are arranged into the _NET_WM_ICON X property, which most
705
+ # modern window managers support.
706
+ # A wm iconbitmap may exist simultaneously.
707
+ # It is recommended to use not more than 2 icons, placing the larger icon
708
+ # first.
709
+ #
710
+ # On Macintosh, this currently does nothing.
711
+ #
712
+ # @see iconphoto_default
713
+ def iconphoto(window, image, *images)
714
+ Tk.execute_only(:wm, :iconphoto, window, image, *images)
715
+ end
716
+
717
+ # If -default is specified, this is applied to all future created toplevels
718
+ # as well.
719
+ #
720
+ # @see iconphoto
721
+ def iconphoto_default(window, image, *images)
722
+ Tk.execute_only(:wm, :iconphoto, window, '-default', image, *images)
723
+ end
724
+
725
+ # If x and y are specified, they are passed to the window manager as a hint
726
+ # about where to position the icon for window.
727
+ # In this case an empty string is returned.
728
+ # If x and y are specified as empty strings then any existing icon position
729
+ # hint is cancelled.
730
+ # If neither x nor y is specified, then the command returns a Tcl list
731
+ # containing two values, which are the current icon position hints (if no
732
+ # hints are in effect then an empty string is returned).
733
+ def iconposition(window, y = None, x = None)
734
+ if y == None || x == None
735
+ Tk.execute_only(:wm, :iconposition, window)
736
+ else
737
+ Tk.execute(:wm, :iconposition, window, y, x)
738
+ end
739
+ end
740
+
741
+ # If pathName is specified, it is the path name for a window to use as icon
742
+ # for window: when window is iconified then pathName will be mapped to serve
743
+ # as icon, and when window is de-iconified then pathName will be unmapped
744
+ # again. If pathName is specified as an empty string then any existing icon
745
+ # window association for window will be cancelled.
746
+ # If the pathName argument is specified then an empty string is returned.
747
+ # Otherwise the command returns the path name of the current icon window for
748
+ # window, or an empty string if there is no icon window currently specified
749
+ # for window.
750
+ # Button press events are disabled for window as long as it is an icon
751
+ # window; this is needed in order to allow window managers to ?own? those
752
+ # events. Note: not all window managers support the notion of an icon
753
+ # window.
754
+ def iconwindow(window, pathname = None)
755
+ if pathname == None
756
+ Tk.execute_only(:wm, :iconwindow, window)
757
+ else
758
+ Tk.execute(:wm, :iconwindow, window, pathname)
759
+ end
760
+ end
761
+
762
+ # The widget specified will become a stand alone top-level window.
763
+ # The window will be decorated with the window managers title bar, etc.
764
+ # Only frame, labelframe and toplevel widgets can be used with this command.
765
+ # Attempting to pass any other widget type will raise an error.
766
+ # Attempting to manage a toplevel widget is benign and achieves nothing.
767
+ # See also GEOMETRY MANAGEMENT.
768
+ def manage(widget)
769
+ Tk.execute_only(:wm, :manage, widget)
770
+ end
771
+
772
+ # If width and height are specified, they give the maximum permissible
773
+ # dimensions for window.
774
+ # For gridded windows the dimensions are specified in grid units; otherwise
775
+ # they are specified in pixel units.
776
+ # The window manager will restrict the window's dimensions to be less than
777
+ # or equal to width and height.
778
+ # If width and height are specified, then the command returns an empty
779
+ # string. Otherwise it returns a Tcl list with two elements, which are the
780
+ # maximum width and height currently in effect.
781
+ # The maximum size defaults to the size of the screen.
782
+ # See the sections on geometry management below for more information.
783
+ def maxsize(window, width = None, height = None)
784
+ if width == None || height == None
785
+ Tk.execute(:wm, :maxsize)
786
+ else
787
+ Tk.execute_only(:wm, :maxsize, width, height)
788
+ end
789
+ end
790
+
791
+ # If width and height are specified, they give the minimum permissible
792
+ # dimensions for window.
793
+ # For gridded windows the dimensions are specified in grid units; otherwise
794
+ # they are specified in pixel units.
795
+ # The window manager will restrict the window's dimensions to be greater
796
+ # than or equal to width and height.
797
+ # If width and height are specified, then the command returns an empty
798
+ # string. Otherwise it returns a Tcl list with two elements, which are the
799
+ # minimum width and height currently in effect.
800
+ # The minimum size defaults to one pixel in each dimension.
801
+ # See the sections on geometry management below for more information.
802
+ def minsize(window, width = None, height = None)
803
+ if width == None || height == None
804
+ Tk.execute(:wm, :minsize, window)
805
+ else
806
+ Tk.execute_only(:wm, :minsize, window, width, height)
807
+ end
808
+ end
809
+
810
+ # If boolean is specified, it must have a proper boolean form and the
811
+ # override-redirect flag for window is set to that value.
812
+ # If boolean is not specified then 1 or 0 is returned to indicate whether or
813
+ # not the override-redirect flag is currently set for window.
814
+ # Setting the override-redirect flag for a window causes it to be ignored by
815
+ # the window manager; among other things, this means that the window will
816
+ # not be reparented from the root window into a decorative frame and the
817
+ # user will not be able to manipulate the window using the normal window
818
+ # manager mechanisms.
819
+ def overrideredirect(window, boolean = None)
820
+ if boolean == None
821
+ Tk.boolean(Tk.execute(:wm, :overrideredirect, window))
822
+ else
823
+ Tk.execute(:wm, :overrideredirect, window, boolean ? true : false)
824
+ end
825
+ end
826
+
827
+ # If who is specified, it must be either program or user, or an abbreviation
828
+ # of one of these two.
829
+ # It indicates whether window's current position was requested by the
830
+ # program or by the user.
831
+ # Many window managers ignore program-requested initial positions and ask
832
+ # the user to manually position the window; if user is specified then the
833
+ # window manager should position the window at the given place without
834
+ # asking the user for assistance.
835
+ # If who is specified as an empty string, then the current position source
836
+ # is cancelled.
837
+ # If who is specified, then the command returns an empty string.
838
+ # Otherwise it returns user or program to indicate the source of the
839
+ # window's current position, or an empty string if no source has been
840
+ # specified yet.
841
+ # Most window managers interpret ?no source? as equivalent to program.
842
+ # Tk will automatically set the position source to user when a wm geometry
843
+ # command is invoked, unless the source has been set explicitly to program.
844
+ def positionfrom(window, who = None)
845
+ if who == None
846
+ Tk.execute_only(:wm, :positionfrom, window, who)
847
+ else
848
+ Tk.execute(:wm, :positionfrom, window)
849
+ end
850
+ end
851
+
852
+ # This command is used to manage window manager protocols such as
853
+ # WM_DELETE_WINDOW. Name is the name of an atom corresponding to a window
854
+ # manager protocol, such as WM_DELETE_WINDOW or WM_SAVE_YOURSELF or
855
+ # WM_TAKE_FOCUS. If both name and command are specified, then command is
856
+ # associated with the protocol specified by name.
857
+ # Name will be added to window's WM_PROTOCOLS property to tell the window
858
+ # manager that the application has a protocol handler for name, and command
859
+ # will be invoked in the future whenever the window manager sends a message
860
+ # to the client for that protocol.
861
+ # In this case the command returns an empty string.
862
+ # If name is specified but command is not, then the current command for name
863
+ # is returned, or an empty string if there is no handler defined for name.
864
+ # If command is specified as an empty string then the current handler for
865
+ # name is deleted and it is removed from the WM_PROTOCOLS property on
866
+ # window; an empty string is returned.
867
+ # Lastly, if neither name nor command is specified, the command returns a
868
+ # list of all the protocols for which handlers are currently defined for
869
+ # window.
870
+ #
871
+ # @example assign protocol handler
872
+ # WM.protocol(window, 'WM_DELETE_WINDOW'){ do_stuff }
873
+ #
874
+ # @example delete protocol handler
875
+ # WM.protocol(window, 'WM_DELETE_WINDOW', nil)
876
+ #
877
+ # @example show protocol handler
878
+ # WM.protocol(window, 'WM_DELETE_WINDOW')
879
+ #
880
+ # @example list protocol handlers
881
+ # WM.protocol(window)
882
+ #
883
+ # Tk always defines a protocol handler for WM_DELETE_WINDOW, even if you
884
+ # have not asked for one with wm protocol.
885
+ # If a WM_DELETE_WINDOW message arrives when you have not defined a handler,
886
+ # then Tk handles the message by destroying the window for which it was
887
+ # received.
888
+ def protocol(window, name = None, command = None, &block)
889
+ command = block if block && !command.nil?
890
+
891
+ if name == None
892
+ Tk.execute(:wm, :protocol, window).to_a
893
+ elsif name != None && command == None
894
+ Tk.execute(:wm, :protocol, name)
895
+ elsif name != None && command.nil?
896
+ Tk.execute_only(:wm, :protocol, name, '')
897
+ elsif name != None && command
898
+ command = register_command(:wm_protocol, &command)
899
+ Tk.execute_only(:wm, :protocol, name, command)
900
+ else
901
+ raise ArgumentError
902
+ end
903
+ end
904
+
905
+ # This command controls whether or not the user may interactively resize a
906
+ # top-level window.
907
+ # If width and height are specified, they are boolean values that determine
908
+ # whether the width and height of window may be modified by the user.
909
+ # In this case the command returns an empty string.
910
+ # If width and height are omitted then the command returns a list with two
911
+ # 0/1 elements that indicate whether the width and height of window are
912
+ # currently resizable.
913
+ # By default, windows are resizable in both dimensions.
914
+ # If resizing is disabled, then the window's size will be the size from the
915
+ # most recent interactive resize or wm geometry command.
916
+ # If there has been no such operation then the window's natural size will be
917
+ # used.
918
+ def resizable(window, width = None, height = None)
919
+ if width == None || height == None
920
+ Tk.execute(:wm, :resizable, window)
921
+ else
922
+ Tk.execute_only(:wm, :resizable, window, width, height)
923
+ end
924
+ end
925
+
926
+ # If who is specified, it must be either program or user, or an abbreviation
927
+ # of one of these two.
928
+ # It indicates whether window's current size was requested by the program or
929
+ # by the user.
930
+ # Some window managers ignore program-requested sizes and ask the user to
931
+ # manually size the window; if user is specified then the window manager
932
+ # should give the window its specified size without asking the user for
933
+ # assistance. If who is specified as an empty string, then the current size
934
+ # source is cancelled.
935
+ # If who is specified, then the command returns an empty string.
936
+ # Otherwise it returns user or window to indicate the source of the window's
937
+ # current size, or an empty string if no source has been specified yet.
938
+ # Most window managers interpret ?no source? as equivalent to program.
939
+ def sizefrom(window, who = None)
940
+ if who == None
941
+ Tk.execute(:wm, :sizefrom, window)
942
+ else
943
+ Tk.execute_only(:wm, :sizefrom, window, who)
944
+ end
945
+ end
946
+
947
+ # The stackorder command returns a list of toplevel windows in stacking
948
+ # order, from lowest to highest.
949
+ # When a single toplevel window is passed, the returned list recursively
950
+ # includes all of the window's children that are toplevels.
951
+ # Only those toplevels that are currently mapped to the screen are returned.
952
+ # The stackorder command can also be used to determine if one toplevel is
953
+ # positioned above or below a second toplevel.
954
+ # When two window arguments separated by either isabove or isbelow are
955
+ # passed, a boolean result indicates whether or not the first window is
956
+ # currently above or below the second window in the stacking order.
957
+ def stackorder(window, order = None, other_window = None)
958
+ if order == None || other_window == None
959
+ Tk.execute(:wm, :stackorder, window)
960
+ else
961
+ Tk.execute_only(:wm, :stackorder, window, order, other_window)
962
+ end
963
+ end
964
+
965
+ # If newstate is specified, the window will be set to the new state,
966
+ # otherwise it returns the current state of window: either normal, iconic,
967
+ # withdrawn, icon, or (Windows and Mac OS X only) zoomed.
968
+ # The difference between iconic and icon is that iconic refers to a window
969
+ # that has been iconified (e.g., with the wm iconify command) while icon
970
+ # refers to a window whose only purpose is to serve as the icon for some
971
+ # other window (via the wm iconwindow command).
972
+ # The icon state cannot be set.
973
+ def state(window, new_state = None)
974
+ if new_state == None
975
+ Tk.execute(:wm, :state, window)
976
+ else
977
+ Tk.execute_only(:wm, :state, window, new_state)
978
+ end
979
+ end
980
+
981
+ # If string is specified, then it will be passed to the window manager for
982
+ # use as the title for window (the window manager should display this string
983
+ # in window's title bar).
984
+ # In this case the command returns an empty string.
985
+ # If string is not specified then the command returns the current title for
986
+ # the window.
987
+ # The title for a window defaults to its name.
988
+ def title(window, string = None)
989
+ if string == None
990
+ Tk.execute(:wm, :title, window)
991
+ else
992
+ Tk.execute_only(:wm, :title, window, string)
993
+ end
994
+ end
995
+
996
+ # If master is specified, then the window manager is informed that window is
997
+ # a transient window (e.g.
998
+ # pull-down menu) working on behalf of master (where master is the path name
999
+ # for a top-level window).
1000
+ # If master is specified as an empty string then window is marked as not
1001
+ # being a transient window any more.
1002
+ # Otherwise the command returns the path name of window's current master, or
1003
+ # an empty string if window is not currently a transient window.
1004
+ # A transient window will mirror state changes in the master and inherit the
1005
+ # state of the master when initially mapped.
1006
+ # It is an error to attempt to make a window a transient of itself.
1007
+ def transient(window, master = None)
1008
+ Tk.execute(:wm, :transient, window, master)
1009
+ end
1010
+
1011
+ # Arranges for window to be withdrawn from the screen.
1012
+ # This causes the window to be unmapped and forgotten about by the window
1013
+ # manager. If the window has never been mapped, then this command causes the
1014
+ # window to be mapped in the withdrawn state.
1015
+ # Not all window managers appear to know how to handle windows that are
1016
+ # mapped in the withdrawn state.
1017
+ # Note: it sometimes seems to be necessary to withdraw a window and then
1018
+ # re-map it (e.g.
1019
+ # with wm deiconify) to get some window managers to pay attention to changes
1020
+ # in window attributes such as group.
1021
+ def withdraw(window)
1022
+ Tk.execute(:wm, :withdraw, window)
1023
+ end
1024
+ end
1025
+ end