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,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../lib/ffi-tk'
4
+
5
+ Tk.init
6
+
7
+ # create notebook widget
8
+ nb = Tk::Tile::Notebook.new
9
+
10
+ text = Tk::Text.new(nb)
11
+ text.value = 'text..'
12
+
13
+ # create labelframe
14
+ @labelframe = Tk::Tile::LabelFrame.new(nb, text: 'label headline').pack
15
+
16
+
17
+ # create buttons inside labelframe
18
+ Tk::Button.new(@labelframe, text: 'Jump Tab') do
19
+ nb.select text
20
+ text.value = "current tab options: " + nb.tab(text).inspect
21
+ end.pack
22
+
23
+ add_button = Tk::Button.new(@labelframe, text: 'Add Tab') do
24
+ t = Tk::Text.new(nb)
25
+ nb.add( t, text: 'new tab' )
26
+ nb.select t
27
+
28
+ t.value = "current tab options: " + nb.tab(t).inspect
29
+
30
+ add_button.configure state: :disabled
31
+ end.pack
32
+
33
+ Tk::Button.new(@labelframe, text: 'Close Example') do
34
+ Tk.exit
35
+ end.pack
36
+
37
+
38
+ # attach labelframe and Tk::Text to notebook widget
39
+ nb.add( @labelframe, text: 'labelframe tab' )
40
+ nb.insert( 0, text, text: 'text tab' )
41
+
42
+
43
+ # select labelframe tab
44
+ nb.select @labelframe
45
+ nb.pack
46
+
47
+
48
+ Tk.mainloop
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../../lib/ffi-tk'
4
+
5
+ Tk.init
6
+
7
+
8
+ Tk::Tile::Style.theme_settings 'alt' do
9
+ Tk::Tile::Style.configure '.', background: 'red'
10
+ Tk::Tile::Style.configure 'test.label', background: 'blue'
11
+
12
+ Tk::Tile::Style.map('.', :background=>[:active, '#694418'])
13
+ end
14
+
15
+
16
+ button1 = Tk::Tile::Button.new('.', text: 'Hello, World!', width: 100) do
17
+ button1.destroy
18
+ Tk.exit
19
+ end
20
+
21
+ button2 = Tk::Tile::Button.new(button1, text: 'Wien!', width: 50) do
22
+ Tk::Tile::Style.map('.', :background=>[:active, '#FFFFFF'])
23
+ button2.destroy
24
+ end
25
+
26
+ #button3 = Tk::Tile::Button.new(button1, text: 'apply theme', style: 'test.label' ) do
27
+ button3 = Tk::Tile::Button.new('.', text: 'apply theme' ) do
28
+ Tk::Tile::Style.theme_use 'alt'
29
+ button3.destroy
30
+ end
31
+ #button3.style 'test.label'
32
+
33
+
34
+ button1.pack
35
+ button2.pack
36
+ button3.pack
37
+
38
+ Tk.mainloop
@@ -0,0 +1,71 @@
1
+ require 'ffi-tk'
2
+ require 'find'
3
+
4
+ class FileTree < Tk::Tile::Treeview
5
+ KB = 1024.0
6
+ MB = KB * KB
7
+ GB = MB * KB
8
+
9
+ def populate_roots
10
+ ## Create the tree and set it up
11
+ configure columns: %w[fullpath type size], displaycolumns: %w[size]
12
+ heading('#0', text: 'Directory Structure')
13
+ heading('size', text: 'File Size')
14
+ column('size', stretch: 0, width: 70)
15
+ bind('<<TreeviewOpen>>'){|event|
16
+ begin
17
+ populate_tree(focus_item)
18
+ rescue Exception => ex
19
+ p ex
20
+ end
21
+
22
+ true
23
+ }
24
+
25
+ Tk.execute('file', 'volumes').sort.each do |volume|
26
+ node = insert(nil, :end, text: volume, values: [volume, 'directory'])
27
+ populate_tree(node)
28
+ end
29
+ end
30
+
31
+ def populate_tree(node)
32
+ return if node.set(:type) != 'directory'
33
+
34
+ path = node.set(:fullpath)
35
+ delete(*node.children.to_a)
36
+
37
+ Dir.glob File.join(path, '*') do |path|
38
+ name, type = File.basename(path), File.ftype(path)
39
+
40
+ item = insert(node, :end, text: name, values: [path, type])
41
+
42
+ if type == 'directory'
43
+ ## Make it so that this node is openable
44
+ dir_item = item.insert(0, text: 'dummy')
45
+ dir_item.options(text: name)
46
+ elsif type == 'file'
47
+ size = File.size(path)
48
+
49
+ if size >= GB
50
+ size = '%.1f GB' % [size / GB]
51
+ elsif size >= MB
52
+ size = '%.1f MB' % [size / MB]
53
+ elsif size >= KB
54
+ size = '%.1f KB' % [size / KB]
55
+ else
56
+ size = '%.1f bytes' % [size]
57
+ end
58
+
59
+ item.set(:size, size)
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ tree = FileTree.new
66
+ tree.bind('<Escape>'){ Tk.exit }
67
+ tree.pack expand: true, fill: :both
68
+ tree.focus
69
+ tree.populate_roots
70
+
71
+ Tk.mainloop
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/ffi-tk'
4
+
5
+ Tk.init
6
+
7
+ Tk.root.bind('Control-c'){|event| p event }
8
+ Tk.root.bind('Control-q'){|event| exit }
9
+
10
+ hello = Tk::Button.new('.', text: 'Push me'){
11
+ Tk::MessageBox.new(message: 'Hello, World!')
12
+ }.pack
13
+
14
+ button = Tk::Button.new('.', text: 'Destroy me!').pack
15
+ button.bind('Enter'){|event| button.destroy }
16
+
17
+ text = Tk::Text.new('.')
18
+ text.insert 'insert', 'Hello, World!'
19
+ text.pack expand: true, fill: :both
20
+
21
+ entry = Tk::Entry.new('.')
22
+ entry.insert 'end', 'Hello, World!'
23
+ entry.pack fill: :x
24
+
25
+ Tk.mainloop
data/example/wait.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'ffi-tk'
2
+
3
+ Tk.init
4
+
5
+ variable = Tk::Variable.new('showstopper', false)
6
+ label = Tk::Label.new(Tk.root, text: 'enter anything to reflect it here').pack
7
+
8
+ entry = Tk::Entry.new(Tk.root, textvariable: variable).pack
9
+ button = Tk::Button.new(Tk.root, text: 'Exit'){ exit }.pack
10
+
11
+ loop do
12
+ Tk::Wait.variable(variable)
13
+ label.configure text: variable.to_s
14
+ end
15
+
16
+ Tk.mainloop
data/ffi-tk.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ffi-tk}
5
+ s.version = "2009.11.29"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Michael 'manveru' Fellinger"]
9
+ s.date = %q{2009-11-29}
10
+ s.description = %q{Pure Ruby FFI wrapper for the Tk GUI toolkit.}
11
+ s.email = %q{m.fellinger@gmail.com}
12
+ s.files = ["CHANGELOG", "MANIFEST", "README.md", "Rakefile", "TODO.md", "bin/rwish", "doc/MIT_LICENSE", "doc/TCL_LICENSE", "example/choose_color.rb", "example/choose_directory.rb", "example/dialog.rb", "example/hello.rb", "example/message_box.rb", "example/option_menu.rb", "example/popup.rb", "example/set_palette.rb", "example/text.rb", "example/tile/kroc_demo_small.rb", "example/tile/kroc_rb_demo.rb", "example/tile/notebook.rb", "example/tile/theme_hello.rb", "example/tile/treeview.rb", "example/various.rb", "example/wait.rb", "ffi-tk.gemspec", "lib/ffi-tk.rb", "lib/ffi-tk/command.rb", "lib/ffi-tk/command/after.rb", "lib/ffi-tk/command/bell.rb", "lib/ffi-tk/command/bind.rb", "lib/ffi-tk/command/bindtags.rb", "lib/ffi-tk/command/cget.rb", "lib/ffi-tk/command/choose_color.rb", "lib/ffi-tk/command/choose_directory.rb", "lib/ffi-tk/command/clipboard.rb", "lib/ffi-tk/command/configure.rb", "lib/ffi-tk/command/destroy.rb", "lib/ffi-tk/command/dialog.rb", "lib/ffi-tk/command/event.rb", "lib/ffi-tk/command/focus.rb", "lib/ffi-tk/command/font.rb", "lib/ffi-tk/command/get_open_file.rb", "lib/ffi-tk/command/get_save_file.rb", "lib/ffi-tk/command/grab.rb", "lib/ffi-tk/command/grid.rb", "lib/ffi-tk/command/image.rb", "lib/ffi-tk/command/lower.rb", "lib/ffi-tk/command/message_box.rb", "lib/ffi-tk/command/option_menu.rb", "lib/ffi-tk/command/pack.rb", "lib/ffi-tk/command/place.rb", "lib/ffi-tk/command/popup.rb", "lib/ffi-tk/command/raise.rb", "lib/ffi-tk/command/scrollable.rb", "lib/ffi-tk/command/selection.rb", "lib/ffi-tk/command/set_palette.rb", "lib/ffi-tk/command/tk_cmd.rb", "lib/ffi-tk/command/vars.rb", "lib/ffi-tk/command/wait.rb", "lib/ffi-tk/command/winfo.rb", "lib/ffi-tk/command/wm.rb", "lib/ffi-tk/core_extensions.rb", "lib/ffi-tk/event/data.rb", "lib/ffi-tk/event/handler.rb", "lib/ffi-tk/ffi/tcl.rb", "lib/ffi-tk/ffi/tcl/cmd_proc.rb", "lib/ffi-tk/ffi/tcl/eval_result.rb", "lib/ffi-tk/ffi/tcl/interp.rb", "lib/ffi-tk/ffi/tcl/obj.rb", "lib/ffi-tk/ffi/tcl/time.rb", "lib/ffi-tk/ffi/tk.rb", "lib/ffi-tk/geometry.rb", "lib/ffi-tk/thread_sender.rb", "lib/ffi-tk/tk.rb", "lib/ffi-tk/variable.rb", "lib/ffi-tk/widget.rb", "lib/ffi-tk/widget/button.rb", "lib/ffi-tk/widget/canvas.rb", "lib/ffi-tk/widget/canvas/arc.rb", "lib/ffi-tk/widget/canvas/bitmap.rb", "lib/ffi-tk/widget/canvas/image.rb", "lib/ffi-tk/widget/canvas/item.rb", "lib/ffi-tk/widget/canvas/line.rb", "lib/ffi-tk/widget/canvas/oval.rb", "lib/ffi-tk/widget/canvas/polygon.rb", "lib/ffi-tk/widget/canvas/rectangle.rb", "lib/ffi-tk/widget/canvas/text.rb", "lib/ffi-tk/widget/canvas/window.rb", "lib/ffi-tk/widget/checkbutton.rb", "lib/ffi-tk/widget/entry.rb", "lib/ffi-tk/widget/frame.rb", "lib/ffi-tk/widget/label.rb", "lib/ffi-tk/widget/labelframe.rb", "lib/ffi-tk/widget/listbox.rb", "lib/ffi-tk/widget/menu.rb", "lib/ffi-tk/widget/menubutton.rb", "lib/ffi-tk/widget/message.rb", "lib/ffi-tk/widget/panedwindow.rb", "lib/ffi-tk/widget/radiobutton.rb", "lib/ffi-tk/widget/root.rb", "lib/ffi-tk/widget/scale.rb", "lib/ffi-tk/widget/scrollbar.rb", "lib/ffi-tk/widget/spinbox.rb", "lib/ffi-tk/widget/text.rb", "lib/ffi-tk/widget/text/peer.rb", "lib/ffi-tk/widget/tile.rb", "lib/ffi-tk/widget/tile/button.rb", "lib/ffi-tk/widget/tile/checkbutton.rb", "lib/ffi-tk/widget/tile/combobox.rb", "lib/ffi-tk/widget/tile/entry.rb", "lib/ffi-tk/widget/tile/frame.rb", "lib/ffi-tk/widget/tile/label.rb", "lib/ffi-tk/widget/tile/labelframe.rb", "lib/ffi-tk/widget/tile/menubutton.rb", "lib/ffi-tk/widget/tile/notebook.rb", "lib/ffi-tk/widget/tile/panedwindow.rb", "lib/ffi-tk/widget/tile/progressbar.rb", "lib/ffi-tk/widget/tile/radiobutton.rb", "lib/ffi-tk/widget/tile/scale.rb", "lib/ffi-tk/widget/tile/scrollbar.rb", "lib/ffi-tk/widget/tile/separator.rb", "lib/ffi-tk/widget/tile/sizegrip.rb", "lib/ffi-tk/widget/tile/style.rb", "lib/ffi-tk/widget/tile/treeview.rb", "lib/ffi-tk/widget/toplevel.rb", "spec/ffi-tk/command/bindtags.rb", "spec/ffi-tk/command/clipboard.rb", "spec/ffi-tk/command/font.rb", "spec/ffi-tk/command/grid.rb", "spec/ffi-tk/command/image.rb", "spec/ffi-tk/command/pack.rb", "spec/ffi-tk/command/place.rb", "spec/ffi-tk/command/selection.rb", "spec/ffi-tk/command/vars.rb", "spec/ffi-tk/command/winfo.rb", "spec/ffi-tk/command/wm.rb", "spec/ffi-tk/event.rb", "spec/ffi-tk/tile/button.rb", "spec/ffi-tk/tile/checkbutton.rb", "spec/ffi-tk/tile/combobox.rb", "spec/ffi-tk/tile/entry.rb", "spec/ffi-tk/tile/frame.rb", "spec/ffi-tk/tile/label.rb", "spec/ffi-tk/tile/labelframe.rb", "spec/ffi-tk/tile/menubutton.rb", "spec/ffi-tk/tile/notebook.rb", "spec/ffi-tk/tile/panedwindow.rb", "spec/ffi-tk/tile/progressbar.rb", "spec/ffi-tk/tile/radiobutton.rb", "spec/ffi-tk/tile/scale.rb", "spec/ffi-tk/tile/scrollbar.rb", "spec/ffi-tk/tile/separator.rb", "spec/ffi-tk/tile/sizegrip.rb", "spec/ffi-tk/tile/style.rb", "spec/ffi-tk/tile/treeview.rb", "spec/ffi-tk/variable.rb", "spec/ffi-tk/widget/button.rb", "spec/ffi-tk/widget/canvas.rb", "spec/ffi-tk/widget/checkbutton.rb", "spec/ffi-tk/widget/entry.rb", "spec/ffi-tk/widget/frame.rb", "spec/ffi-tk/widget/label.rb", "spec/ffi-tk/widget/labelframe.rb", "spec/ffi-tk/widget/listbox.rb", "spec/ffi-tk/widget/menu.rb", "spec/ffi-tk/widget/menubutton.rb", "spec/ffi-tk/widget/message.rb", "spec/ffi-tk/widget/panedwindow.rb", "spec/ffi-tk/widget/radiobutton.rb", "spec/ffi-tk/widget/root.rb", "spec/ffi-tk/widget/scale.rb", "spec/ffi-tk/widget/scrollbar.rb", "spec/ffi-tk/widget/spinbox.rb", "spec/ffi-tk/widget/text.rb", "spec/ffi-tk/widget/toplevel.rb", "spec/helper.rb", "tasks/authors.rake", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/gem.rake", "tasks/gem_setup.rake", "tasks/grancher.rake", "tasks/manifest.rake", "tasks/rcov.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/ycov.rake"]
13
+ s.homepage = %q{http://github.com/manveru/ffi-tk}
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = %q{1.3.5}
16
+ s.summary = %q{Pure Ruby FFI wrapper for the Tk GUI toolkit.}
17
+
18
+ if s.respond_to? :specification_version then
19
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
20
+ s.specification_version = 3
21
+
22
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
23
+ s.add_runtime_dependency(%q<ffi>, ["~> 0.5.1"])
24
+ s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
25
+ else
26
+ s.add_dependency(%q<ffi>, ["~> 0.5.1"])
27
+ s.add_dependency(%q<bacon>, [">= 1.1.0"])
28
+ end
29
+ else
30
+ s.add_dependency(%q<ffi>, ["~> 0.5.1"])
31
+ s.add_dependency(%q<bacon>, [">= 1.1.0"])
32
+ end
33
+ end
data/lib/ffi-tk.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'thread'
2
+ require 'ffi'
3
+
4
+ $LOAD_PATH.unshift File.dirname(__FILE__)
5
+
6
+ module Tk
7
+ LIBPATH = { tcl: [], tk: [] }
8
+
9
+ if ENV['Apple_PubSub_Socket_Render']
10
+ RUN_EVENTLOOP_ON_MAIN_THREAD = true
11
+
12
+ if ENV['NO_AQUA'] || ENV['USE_X11'] # macports-x11 libtk
13
+ LIBPATH[:tcl] << '/opt/local/lib/libtcl8.5.dylib'
14
+ LIBPATH[:tk] << '/opt/local/lib/libtk8.5.dylib'
15
+ else # Tcl/Tk Aqua >= 8.5
16
+ LIBPATH[:tcl] << '/Library/Frameworks/Tcl.framework/Tcl'
17
+ LIBPATH[:tk] << '/Library/Frameworks/Tk.framework/Tk'
18
+ end
19
+ end
20
+ end
21
+
22
+ require 'ffi-tk/thread_sender'
23
+ require 'ffi-tk/ffi/tcl'
24
+ require 'ffi-tk/ffi/tk'
25
+
26
+ module Tk
27
+ Error = Class.new(RuntimeError)
28
+
29
+ OK = 0
30
+ ERROR = 1
31
+ RETURN = 2
32
+ BREAK = 3
33
+ CONTINUE = 4
34
+
35
+ None = Object.new
36
+
37
+ class << None
38
+ def to_tcl; nil; end
39
+ def to_tcl_options?; self; end
40
+ def to_tcl_option?; self; end
41
+ def inspect; '#<None>'; end
42
+ end
43
+
44
+ autoload :Button, 'ffi-tk/widget/button'
45
+ autoload :Canvas, 'ffi-tk/widget/canvas'
46
+ autoload :CheckButton, 'ffi-tk/widget/checkbutton'
47
+ autoload :Entry, 'ffi-tk/widget/entry'
48
+ autoload :Frame, 'ffi-tk/widget/frame'
49
+ autoload :Label, 'ffi-tk/widget/label'
50
+ autoload :LabelFrame, 'ffi-tk/widget/labelframe'
51
+ autoload :Listbox, 'ffi-tk/widget/listbox'
52
+ autoload :Menu, 'ffi-tk/widget/menu'
53
+ autoload :MenuButton, 'ffi-tk/widget/menubutton'
54
+ autoload :Message, 'ffi-tk/widget/message'
55
+ autoload :PanedWindow, 'ffi-tk/widget/panedwindow'
56
+ autoload :RadioButton, 'ffi-tk/widget/radiobutton'
57
+ autoload :Root, 'ffi-tk/widget/root'
58
+ autoload :Scale, 'ffi-tk/widget/scale'
59
+ autoload :Scrollbar, 'ffi-tk/widget/scrollbar'
60
+ autoload :Spinbox, 'ffi-tk/widget/spinbox'
61
+ autoload :Text, 'ffi-tk/widget/text'
62
+ autoload :Toplevel, 'ffi-tk/widget/toplevel'
63
+
64
+ autoload :Tile, 'ffi-tk/widget/tile'
65
+
66
+ require 'ffi-tk/core_extensions'
67
+ require 'ffi-tk/geometry'
68
+ require 'ffi-tk/event/data'
69
+ require 'ffi-tk/event/handler'
70
+ require 'ffi-tk/variable'
71
+ require 'ffi-tk/command'
72
+ require 'ffi-tk/widget'
73
+
74
+ # require the real thing
75
+ require 'ffi-tk/tk'
76
+ end
@@ -0,0 +1,39 @@
1
+ module Tk
2
+ require 'ffi-tk/command/choose_color'
3
+ require 'ffi-tk/command/choose_directory'
4
+ require 'ffi-tk/command/event'
5
+ require 'ffi-tk/command/get_open_file'
6
+ require 'ffi-tk/command/get_save_file'
7
+ require 'ffi-tk/command/message_box'
8
+ require 'ffi-tk/command/option_menu'
9
+ require 'ffi-tk/command/popup'
10
+ require 'ffi-tk/command/set_palette'
11
+ require 'ffi-tk/command/vars'
12
+
13
+ autoload :After, 'ffi-tk/command/after'
14
+ autoload :Bell, 'ffi-tk/command/bell'
15
+ autoload :Bind, 'ffi-tk/command/bind'
16
+ autoload :BindTag, 'ffi-tk/command/bindtags'
17
+ autoload :Bindtags, 'ffi-tk/command/bindtags'
18
+ autoload :Cget, 'ffi-tk/command/cget'
19
+ autoload :Clipboard, 'ffi-tk/command/clipboard'
20
+ autoload :Configure, 'ffi-tk/command/configure'
21
+ autoload :Destroy, 'ffi-tk/command/destroy'
22
+ autoload :Dialog, 'ffi-tk/command/dialog'
23
+ autoload :Focus, 'ffi-tk/command/focus'
24
+ autoload :Font, 'ffi-tk/command/font'
25
+ autoload :Grab, 'ffi-tk/command/grab'
26
+ autoload :Grid, 'ffi-tk/command/grid'
27
+ autoload :Grid, 'ffi-tk/command/grid'
28
+ autoload :Image, 'ffi-tk/command/image'
29
+ autoload :Lower, 'ffi-tk/command/lower'
30
+ autoload :Pack, 'ffi-tk/command/pack'
31
+ autoload :Place, 'ffi-tk/command/place'
32
+ autoload :Raise, 'ffi-tk/command/raise'
33
+ autoload :Selection, 'ffi-tk/command/selection'
34
+ autoload :TkCmd, 'ffi-tk/command/tk_cmd'
35
+ autoload :WM, 'ffi-tk/command/wm'
36
+ autoload :Wait, 'ffi-tk/command/wait'
37
+ autoload :Winfo, 'ffi-tk/command/winfo'
38
+ autoload :Scrollable,'ffi-tk/command/scrollable'
39
+ end
@@ -0,0 +1,36 @@
1
+ module Tk
2
+ module After
3
+ module_function
4
+
5
+ def ms(ms)
6
+ if block_given?
7
+ id = nil
8
+ block = Proc.new
9
+
10
+ wrap = lambda{|*args|
11
+ block.call
12
+ Tk.unregister_proc(id)
13
+ true
14
+ }
15
+
16
+ id, command = Tk.register_proc(wrap, 'after_ms')
17
+ Tk.execute_only(:after, ms, command)
18
+ else
19
+ Tk.execute_only(:after, ms)
20
+ end
21
+ end
22
+
23
+ def idle(&block)
24
+ id = nil
25
+
26
+ wrap = lambda{|*args|
27
+ block.call
28
+ Tk.unregister_proc(id)
29
+ true
30
+ }
31
+
32
+ id, command = Tk.register_proc(wrap, 'after_idle')
33
+ Tk.execute_only(:after, :idle, command)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,34 @@
1
+ module Tk
2
+ module Bell
3
+ # This command rings the bell on the display for window and returns an empty
4
+ # string.
5
+ # If the :displayof option is omitted, the display of the application's main
6
+ # window is used by default.
7
+ # The command uses the current bell-related settings for the display, which
8
+ # may be modified with programs such as xset.
9
+ #
10
+ # If :nice is not specified, this command also resets the screen saver for
11
+ # the screen. Some screen savers will ignore this, but others will reset so
12
+ # that the screen becomes visible again.
13
+ #
14
+ # @example Usage:
15
+ # Tk::Bell.bell
16
+ # Tk::Bell.bell(displayof: '.')
17
+ # Tk::Bell.bell(nice: true)
18
+ # Tk::Bell.bell(displayof: '.', nice: true)
19
+ def self.bell(options = {})
20
+ displayof = options[:displayof]
21
+ nice = options[:nice]
22
+
23
+ args = []
24
+ args << '-displayof' << displayof if displayof
25
+ args << '-nice' if nice
26
+ Tk.execute_only('bell', *args)
27
+ end
28
+
29
+ def bell(options = {})
30
+ options[:displayof] ||= tk_pathname
31
+ Bell.bell(options)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ module Tk
2
+ module Bind
3
+ def self.bind(pathname, sequence, &block)
4
+ Event::Handler.register(pathname, sequence, &block)
5
+ end
6
+
7
+ def bind(sequence, &block)
8
+ Bind.bind(tk_pathname, sequence, &block)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,69 @@
1
+ module Tk
2
+ # Determine which bindings apply to a window, and order of evaluation
3
+ #
4
+ # When a binding is created with the [Bind.bind] command, it is associated
5
+ # either with a particular window such as .a.b.c, a class name such as Button,
6
+ # the keyword all, or any other string.
7
+ # All of these forms are called binding tags.
8
+ # Each window contains a list of binding tags that determine how events are
9
+ # processed for the window.
10
+ #
11
+ # When an event occurs in a window, it is applied to each of the window's tags
12
+ # in order: for each tag, the most specific binding that matches the given tag
13
+ # and event is executed.
14
+ #
15
+ # See the [Bind.bind] command for more information on the matching process.
16
+ module Bindtags
17
+ # By default, each window has four binding tags consisting of the name of
18
+ # the window, the window's class name, the name of the window's nearest
19
+ # toplevel ancestor, and all, in that order.
20
+ # Toplevel windows have only three tags by default, since the toplevel name
21
+ # is the same as that of the window.
22
+ # The bindtags command allows the binding tags for a window to be read and
23
+ # modified.
24
+ #
25
+ # If bindtags is invoked with only one argument, then the current set of
26
+ # binding tags for +window+ is returned as a list.
27
+ # If the +taglist+ argument is specified to bindtags, then it must be a
28
+ # proper list; the tags for +window+ are changed to the elements of the
29
+ # list. The elements of +taglist+ may be arbitrary strings; however, any tag
30
+ # starting with a dot is treated as the name of a window; if no window by
31
+ # that name exists at the time an event is processed, then the tag is
32
+ # ignored for that event.
33
+ # The order of the elements in +taglist+ determines the order in which
34
+ # binding scripts are executed in response to events.
35
+ #
36
+ # @example reversing order for .b
37
+ # tags = Bindtags.bindtags('.b')
38
+ # Bindtags.bindtags('.b', *tags.reverse)
39
+ #
40
+ # The above example reverses the order in which binding scripts will be
41
+ # evaluated for a button named `.b` so that all bindings are invoked first,
42
+ # following by bindings for `.b`'s toplevel (`.`), followed by class
43
+ # bindings, followed by bindings for `.b`.
44
+ # If +taglist+ is an empty list then the binding tags for +window+ are
45
+ # returned to the default state described above.
46
+ def self.bindtags(window, *taglist)
47
+ if taglist.empty?
48
+ Tk.execute(:bindtags, window)
49
+ else
50
+ taglist = taglist.flatten
51
+ Tk.execute(:bindtags, window, taglist)
52
+ end
53
+ end
54
+
55
+ def bindtags(*taglist)
56
+ Bindtags.bindtags(self, *taglist)
57
+ end
58
+ end
59
+
60
+ class BindTag < Struct.new(:name)
61
+ def bind(sequence, &block)
62
+ Bind.bind(name, sequence, &block)
63
+ end
64
+
65
+ def to_tcl
66
+ TclString.new(name)
67
+ end
68
+ end
69
+ end