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,70 @@
1
+ module Tk
2
+ # Utility methods for managing the input focus.
3
+ module Focus
4
+ module_function
5
+
6
+ def focus(window = None, option = None)
7
+ if window == None
8
+ Tk.execute('focus')
9
+ else
10
+ case option
11
+ when None
12
+ Tk.execute('focus', window)
13
+ when :displayof
14
+ Tk.execute('focus', '-displayof', window)
15
+ when :force
16
+ Tk.execute_only('focus', '-force', window)
17
+ when :lastfor
18
+ Tk.execute('focus', '-lastfor', window)
19
+ else
20
+ raise ArgumentError, "option must be one of: None, :displayof, :force, :lastfor"
21
+ end
22
+ end
23
+ end
24
+
25
+ # This method changes the focus model for the application to an implicit one
26
+ # where the window under the mouse gets the focus.
27
+ # After this method is called, whenever the mouse enters a window Tk will
28
+ # automatically give it the input focus.
29
+ # The focus command may be used to move the focus to a window other than the
30
+ # one under the mouse, but as soon as the mouse moves into a new window the
31
+ # focus will jump to that window.
32
+ #
33
+ # Note: at present there is no built-in support for returning the
34
+ # application to an explicit focus model; to do this you will have to write
35
+ # a script that deletes the bindings created by tk_focusFollowsMouse.
36
+ def follows_mouse
37
+ Tk.execute_only(:tk_focusFollowsMouse)
38
+ end
39
+
40
+ # A method used for keyboard traversal.
41
+ # It returns the "next" window after +window+ in focus order.
42
+ #
43
+ # The focus order is determined by the stacking order of windows and the
44
+ # structure of the window hierarchy.
45
+ # Among siblings, the focus order is the same as the stacking order, with
46
+ # the lowest window being first.
47
+ #
48
+ # If a window has children, the window is visited first, followed by its
49
+ # children (recursively), followed by its next sibling.
50
+ #
51
+ # Top-level windows other than +window+ are skipped, so that it never
52
+ # returns a window in a different top-level from +window+.
53
+ #
54
+ # After computing the next window, it examines the window's :takefocus
55
+ # option to see whether it should be skipped.
56
+ #
57
+ # If so, it continues on to the next window in the focus order, until it
58
+ # eventually finds a window that will accept the focus or returns back to
59
+ # window.
60
+ def next(window)
61
+ Tk.execute(:tk_focusNext, window)
62
+ end
63
+
64
+ # Similar to [Focus.next], except that it returns the window just before
65
+ # +window+ in the focus order.
66
+ def prev(window)
67
+ Tk.execute(:tk_focusPrev, window)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,124 @@
1
+ module Tk
2
+ # Create and inspect fonts.
3
+ # The font command provides several facilities for dealing with fonts, such as
4
+ # defining named fonts and inspecting the actual attributes of a font.
5
+ class Font
6
+ def initialize(string_or_hash)
7
+ if string_or_hash.respond_to?(:to_str)
8
+ string_or_hash =~ /^(.*)\s+(\d+)?$/
9
+
10
+ params = {}
11
+ params[:family] = $1.to_s
12
+ params[:size] = $2.to_i if $2
13
+
14
+ @font = Font.create(params)
15
+ elsif string_or_hash.respond_to?(:to_hash)
16
+ @font = Font.create(string_or_hash)
17
+ else
18
+ raise ArgumentError
19
+ end
20
+ end
21
+
22
+ def actual(options = {})
23
+ Font.actual(@font, options)
24
+ end
25
+
26
+ def actual_hash(options = {})
27
+ Font.actual(@font, options)
28
+ end
29
+
30
+ def measure(text, options = {})
31
+ Font.measure(@font, text, options)
32
+ end
33
+
34
+ def metrics(option, options = {})
35
+ Font.metrics(@font, option, options)
36
+ end
37
+
38
+ def configure(argument = None)
39
+ Font.configure(@font, argument)
40
+ end
41
+
42
+ def to_tcl
43
+ TclString.new(@font)
44
+ end
45
+
46
+ FONT_CONFIGURE_HINTS = {
47
+ underline: :boolean,
48
+ overstrike: :boolean,
49
+ weight: :symbol,
50
+ slant: :symbol,
51
+ }
52
+
53
+ def self.execute(command, *args)
54
+ Tk.execute(:font, command, *args)
55
+ end
56
+
57
+ def self.execute_only(command, *args)
58
+ Tk.execute_only(:font, command, *args)
59
+ end
60
+
61
+ # NOTE:
62
+ # the signature has been simplified to a required +font+ argument and a
63
+ # simple +options+ hash.
64
+ # The original signature is:
65
+ # `font actual font ?-displayof window? ?option? ?--? ?char?`
66
+ # But it just makes things very painful.
67
+ # @options
68
+ # :displayof window
69
+ # :char char
70
+ # :option name
71
+ def self.actual(font, options = {})
72
+ window = options.fetch(:displayof, None)
73
+ option = options.fetch(:option, None)
74
+ char = options.fetch(:char, None)
75
+
76
+ args = []
77
+ args << "-displayof" << window unless window == None
78
+ args << option.to_tcl_option unless option == None
79
+ args << "--" << char.to_tcl unless char == None
80
+
81
+ array = execute(:actual, font, *args)
82
+ array.tcl_options_to_hash(FONT_CONFIGURE_HINTS)
83
+ end
84
+
85
+ def self.configure(fontname, argument = None)
86
+ Configure.common(
87
+ self, [:configure, fontname], argument, FONT_CONFIGURE_HINTS)
88
+ end
89
+
90
+ def self.create(fontname, options = None)
91
+ if fontname.respond_to?(:to_tcl_options)
92
+ fontname, options = None, fontname
93
+ options = options.to_tcl_options
94
+ end
95
+
96
+ execute(:create, fontname, options)
97
+ end
98
+
99
+ def self.delete(*fontnames)
100
+ execute(:delete, *fontnames)
101
+ end
102
+
103
+ # The return value is a list of the case-insensitive names of all font
104
+ # families that exist on window's display.
105
+ # If the window argument is omitted, it defaults to the main window.
106
+ def self.families(options = {})
107
+ execute(:families, options.to_tcl_options)
108
+ end
109
+
110
+ def self.measure(font, text, options = {})
111
+ execute(:measure, font, options.to_tcl_options, text)
112
+ end
113
+
114
+ def self.metrics(font, option, options = {})
115
+ execute(:metrics, font, options.to_tcl_options, option.to_tcl_option)
116
+ end
117
+
118
+ # The return value is a list of all the named fonts that are currently
119
+ # defined.
120
+ def self.names
121
+ execute(:names).to_a
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,85 @@
1
+ module Tk
2
+ module_function
3
+
4
+ # Pop up a dialog box for the user to select a file to open.
5
+ #
6
+ # This method is usually associated with the "Open" command in the "File"
7
+ # menu.
8
+ # Its purpose is for the user to select an existing file only.
9
+ # If the user enters a non-existing file, the dialog box gives the user an
10
+ # error prompt and requires the user to give an alternative selection.
11
+ # If an application allows the user to create new files, it should do so by
12
+ # providing a separate "New" command in the "File" menu.
13
+ #
14
+ # If a user selects a file, the full pathname of the file is returned.
15
+ # If the user cancels the dialog, nil is returned.
16
+ #
17
+ # The following options may be given:
18
+ #
19
+ # defaultextension: extension
20
+ # Specifies a string that will be appended to the filename if the user
21
+ # enters a filename without an extension.
22
+ # The default value is the empty string, which means no extension will be
23
+ # appended to the filename in any case.
24
+ # This option is ignored on Mac OS X, which does not require extensions to
25
+ # filenames, and the UNIX implementation guesses reasonable values for
26
+ # this from the :filetypes option when this is not supplied.
27
+ #
28
+ # filetypes: file_pattern_list
29
+ # If a File types listbox exists in the file dialog on the particular
30
+ # platform, this option gives the filetypes in this listbox.
31
+ # When the user choose a filetype in the listbox, only the files of that
32
+ # type are listed.
33
+ # If this option is unspecified, or if it is set to the empty list, or if
34
+ # the File types listbox is not supported by the particular platform then
35
+ # all files are listed regardless of their types.
36
+ #
37
+ # initialdir: directory
38
+ # Specifies that the files in directory should be displayed when the
39
+ # dialog pops up.
40
+ # If this parameter is not specified, then the files in the current
41
+ # working directory are displayed.
42
+ # If the parameter specifies a relative path, the return value will
43
+ # convert the relative path to an absolute path.
44
+ #
45
+ # initialfile: filename
46
+ # Specifies a filename to be displayed in the dialog when it pops up.
47
+ #
48
+ # message: string
49
+ # Specifies a message to include in the client area of the dialog.
50
+ # This is only available on Mac OS X.
51
+ #
52
+ # multiple: boolean
53
+ # Allows the user to choose multiple files from the dialog.
54
+ #
55
+ # parent: window
56
+ # Makes window the logical parent of the file dialog.
57
+ # The file dialog is displayed on top of its parent window.
58
+ # On Mac OS X, this turns the file dialog into a sheet attached to the
59
+ # parent window.
60
+ #
61
+ # title: string
62
+ # Specifies a string to display as the title of the dialog box.
63
+ # If this option is not specified, then a default title is displayed.
64
+ #
65
+ # On the Unix and Macintosh platforms, extensions are matched using glob-style
66
+ # pattern matching.
67
+ # On the Windows platform, extensions are matched by the underlying operating
68
+ # system.
69
+ #
70
+ # The types of possible extensions are:
71
+ # * the special extension "*" matches any file
72
+ # * the special extension "" matches any files that do not have an extension
73
+ # (i.e., the filename contains no full stop character)
74
+ # * any character string that does not contain any wild card characters ("*"
75
+ # and "?").
76
+ #
77
+ # Due to the different pattern matching rules on the various platforms, to
78
+ # ensure portability, wild card characters are not allowed in the extensions,
79
+ # except as in the special extension "*".
80
+ # Extensions without a full stop character (e.g. "~") are allowed but may not
81
+ # work on all platforms.
82
+ def get_open_file(options = None)
83
+ Tk.execute(:tk_getOpenFile, options.to_tcl_options?)
84
+ end
85
+ end
@@ -0,0 +1,83 @@
1
+ module Tk
2
+ module_function
3
+
4
+ # Pop up a dialog box for the user to select a file to save.
5
+ #
6
+ # This method is usually associated with the "Save as" command in the "File"
7
+ # menu.
8
+ # If the user enters a file that already exists, the dialog box prompts the
9
+ # user for confirmation whether the existing file should be overwritten or
10
+ # not.
11
+ #
12
+ # If a user selects a file, the full pathname of the file is returned.
13
+ # If the user cancels the dialog, nil is returned.
14
+ #
15
+ # The following options may be given:
16
+ #
17
+ # defaultextension: extension
18
+ # Specifies a string that will be appended to the filename if the user
19
+ # enters a filename without an extension.
20
+ # The default value is the empty string, which means no extension will be
21
+ # appended to the filename in any case.
22
+ # This option is ignored on Mac OS X, which does not require extensions to
23
+ # filenames, and the UNIX implementation guesses reasonable values for
24
+ # this from the :filetypes option when this is not supplied.
25
+ #
26
+ # filetypes: file_pattern_list
27
+ # If a File types listbox exists in the file dialog on the particular
28
+ # platform, this option gives the filetypes in this listbox.
29
+ # When the user choose a filetype in the listbox, only the files of that
30
+ # type are listed.
31
+ # If this option is unspecified, or if it is set to the empty list, or if
32
+ # the File types listbox is not supported by the particular platform then
33
+ # all files are listed regardless of their types.
34
+ #
35
+ # initialdir: directory
36
+ # Specifies that the files in directory should be displayed when the
37
+ # dialog pops up.
38
+ # If this parameter is not specified, then the files in the current
39
+ # working directory are displayed.
40
+ # If the parameter specifies a relative path, the return value will
41
+ # convert the relative path to an absolute path.
42
+ #
43
+ # initialfile: filename
44
+ # Specifies a filename to be displayed in the dialog when it pops up.
45
+ #
46
+ # message: string
47
+ # Specifies a message to include in the client area of the dialog.
48
+ # This is only available on Mac OS X.
49
+ #
50
+ # multiple: boolean
51
+ # Allows the user to choose multiple files from the dialog.
52
+ #
53
+ # parent: window
54
+ # Makes window the logical parent of the file dialog.
55
+ # The file dialog is displayed on top of its parent window.
56
+ # On Mac OS X, this turns the file dialog into a sheet attached to the
57
+ # parent window.
58
+ #
59
+ # title: string
60
+ # Specifies a string to display as the title of the dialog box.
61
+ # If this option is not specified, then a default title is displayed.
62
+ #
63
+ # On the Unix and Macintosh platforms, extensions are matched using glob-style
64
+ # pattern matching.
65
+ # On the Windows platform, extensions are matched by the underlying operating
66
+ # system.
67
+ #
68
+ # The types of possible extensions are:
69
+ # * the special extension "*" matches any file
70
+ # * the special extension "" matches any files that do not have an extension
71
+ # (i.e., the filename contains no full stop character)
72
+ # * any character string that does not contain any wild card characters ("*"
73
+ # and "?").
74
+ #
75
+ # Due to the different pattern matching rules on the various platforms, to
76
+ # ensure portability, wild card characters are not allowed in the extensions,
77
+ # except as in the special extension "*".
78
+ # Extensions without a full stop character (e.g. "~") are allowed but may not
79
+ # work on all platforms.
80
+ def get_save_file(options = None)
81
+ Tk.execute(:tk_getSaveFile, options.to_tcl_options?)
82
+ end
83
+ end
@@ -0,0 +1,141 @@
1
+ module Tk
2
+ # Confine pointer and keyboard events to a window sub-tree
3
+ #
4
+ #
5
+ # WARNING
6
+ #
7
+ # It is very easy to use global grabs to render a display completely unusable
8
+ # (e.g. by setting a grab on a widget which does not respond to events and not
9
+ # providing any mechanism for releasing the grab).
10
+ # Take extreme care when using them!
11
+ #
12
+ #
13
+ # DESCRIPTION
14
+ #
15
+ # This command implements simple pointer and keyboard grabs for Tk.
16
+ #
17
+ # Tk's grabs are different than the grabs described in the Xlib documentation.
18
+ # When a grab is set for a particular window, Tk restricts all pointer events
19
+ # to the grab window and its descendants in Tk's window hierarchy.
20
+ #
21
+ # Whenever the pointer is within the grab window's subtree, the pointer will
22
+ # behave exactly the same as if there had been no grab at all and all events
23
+ # will be reported in the normal fashion.
24
+ # When the pointer is outside window's tree, button presses and releases and
25
+ # mouse motion events are reported to window, and window entry and window exit
26
+ # events are ignored.
27
+ #
28
+ # The grab subtree “owns” the pointer: windows outside the grab subtree
29
+ # will be visible on the screen but they will be insensitive until the grab is
30
+ # released. The tree of windows underneath the grab window can include
31
+ # top-level windows, in which case all of those top-level windows and their
32
+ # descendants will continue to receive mouse events during the grab.
33
+ # Two forms of grabs are possible: local and global.
34
+ # A local grab affects only the grabbing application: events will be reported
35
+ # to other applications as if the grab had never occurred.
36
+ # Grabs are local by default.
37
+ #
38
+ # A global grab locks out all applications on the screen, so that only the
39
+ # given subtree of the grabbing application will be sensitive to pointer
40
+ # events (mouse button presses, mouse button releases, pointer motions, window
41
+ # entries, and window exits).
42
+ #
43
+ # During global grabs the window manager will not receive pointer events
44
+ # either. During local grabs, keyboard events (key presses and key releases)
45
+ # are delivered as usual: the window manager controls which application
46
+ # receives keyboard events, and if they are sent to any window in the grabbing
47
+ # application then they are redirected to the focus window.
48
+ # During a global grab Tk grabs the keyboard so that all keyboard events are
49
+ # always sent to the grabbing application.
50
+ #
51
+ # The focus command is still used to determine which window in the application
52
+ # receives the keyboard events.
53
+ # The keyboard grab is released when the grab is released.
54
+ #
55
+ # Grabs apply to particular displays.
56
+ # If an application has windows on multiple displays then it can establish a
57
+ # separate grab on each display.
58
+ # The grab on a particular display affects only the windows on that display.
59
+ # It is possible for different applications on a single display to have
60
+ # simultaneous local grabs, but only one application can have a global grab on
61
+ # a given display at once.
62
+ module Grab
63
+ # @see Grab.global
64
+ def grab_global(window)
65
+ Grab.globa(self)
66
+ end
67
+
68
+ # @see Grab.local
69
+ def grab_local
70
+ Grab.local(self)
71
+ end
72
+
73
+ # @see Grab.current
74
+ def grab_current
75
+ Grab.current(self)
76
+ end
77
+
78
+ # @see Grab.release
79
+ def grab_release
80
+ Grab.release(self)
81
+ end
82
+
83
+ # @see Grab.set_global
84
+ def grab_set_global
85
+ Grab.set_global(self)
86
+ end
87
+
88
+ # @see Grab.set_local
89
+ def grab_set_local
90
+ Grab.set_local(self)
91
+ end
92
+
93
+ module_function
94
+
95
+ # Same as [set_global], described below.
96
+ def global(window)
97
+ Tk.execute(:grab, '-global', window)
98
+ end
99
+
100
+ # Same as [set_local], described below.
101
+ def local(window)
102
+ Tk.execute(:grab, window)
103
+ end
104
+
105
+ # If window is specified, returns the name of the current grab window in
106
+ # this application for window's display, or an empty string if there is no
107
+ # such window.
108
+ # If window is omitted, the command returns a list whose elements are all
109
+ # of the windows grabbed by this application for all displays, or an empty
110
+ # string if the application has no grabs.
111
+ def current(window = None)
112
+ if None == window
113
+ Tk.execute(:grab, :current).to_a
114
+ else
115
+ Tk.execute(:grab, :current, window).to_s?
116
+ end
117
+ end
118
+
119
+ # Releases the grab on window if there is one, otherwise does nothing.
120
+ # Returns an empty string.
121
+ def release(window)
122
+ Tk.execute_only(:grab, :release, window)
123
+ end
124
+
125
+ # Sets a local grab on window.
126
+ # If a grab was already in effect for this application on +window+'s display
127
+ # then it is automatically released.
128
+ # Does nothing if there is already a local grab on +window+.
129
+ def set_local(window)
130
+ Tk.execute(:grab, :set, window)
131
+ end
132
+
133
+ # Sets a global grab on window.
134
+ # If a grab was already in effect for this application on +window+'s display
135
+ # then it is automatically released.
136
+ # Does nothing if there is already a global grab on +window+.
137
+ def set_global(window)
138
+ Tk.execute(:grab, :set, '-global', window)
139
+ end
140
+ end
141
+ end