tk-win 0.2.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (329) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +46 -0
  6. data/VERSION +1 -0
  7. data/lib/tcltk.rb +367 -0
  8. data/lib/tk.rb +5682 -0
  9. data/lib/tk/after.rb +6 -0
  10. data/lib/tk/autoload.rb +760 -0
  11. data/lib/tk/bgerror.rb +29 -0
  12. data/lib/tk/bindtag.rb +138 -0
  13. data/lib/tk/button.rb +31 -0
  14. data/lib/tk/canvas.rb +816 -0
  15. data/lib/tk/canvastag.rb +459 -0
  16. data/lib/tk/checkbutton.rb +32 -0
  17. data/lib/tk/clipboard.rb +75 -0
  18. data/lib/tk/clock.rb +71 -0
  19. data/lib/tk/composite.rb +484 -0
  20. data/lib/tk/console.rb +52 -0
  21. data/lib/tk/dialog.rb +326 -0
  22. data/lib/tk/encodedstr.rb +187 -0
  23. data/lib/tk/entry.rb +120 -0
  24. data/lib/tk/event.rb +562 -0
  25. data/lib/tk/font.rb +2351 -0
  26. data/lib/tk/frame.rb +132 -0
  27. data/lib/tk/grid.rb +279 -0
  28. data/lib/tk/image.rb +275 -0
  29. data/lib/tk/itemconfig.rb +1222 -0
  30. data/lib/tk/itemfont.rb +327 -0
  31. data/lib/tk/kinput.rb +71 -0
  32. data/lib/tk/label.rb +22 -0
  33. data/lib/tk/labelframe.rb +31 -0
  34. data/lib/tk/listbox.rb +284 -0
  35. data/lib/tk/macpkg.rb +80 -0
  36. data/lib/tk/menu.rb +718 -0
  37. data/lib/tk/menubar.rb +137 -0
  38. data/lib/tk/menuspec.rb +456 -0
  39. data/lib/tk/message.rb +24 -0
  40. data/lib/tk/mngfocus.rb +33 -0
  41. data/lib/tk/msgcat.rb +296 -0
  42. data/lib/tk/namespace.rb +551 -0
  43. data/lib/tk/optiondb.rb +377 -0
  44. data/lib/tk/optionobj.rb +212 -0
  45. data/lib/tk/pack.rb +107 -0
  46. data/lib/tk/package.rb +143 -0
  47. data/lib/tk/palette.rb +55 -0
  48. data/lib/tk/panedwindow.rb +260 -0
  49. data/lib/tk/place.rb +128 -0
  50. data/lib/tk/radiobutton.rb +73 -0
  51. data/lib/tk/root.rb +95 -0
  52. data/lib/tk/scale.rb +112 -0
  53. data/lib/tk/scrollable.rb +82 -0
  54. data/lib/tk/scrollbar.rb +183 -0
  55. data/lib/tk/scrollbox.rb +39 -0
  56. data/lib/tk/selection.rb +86 -0
  57. data/lib/tk/spinbox.rb +144 -0
  58. data/lib/tk/tagfont.rb +43 -0
  59. data/lib/tk/text.rb +1604 -0
  60. data/lib/tk/textimage.rb +88 -0
  61. data/lib/tk/textmark.rb +204 -0
  62. data/lib/tk/texttag.rb +321 -0
  63. data/lib/tk/textwindow.rb +154 -0
  64. data/lib/tk/timer.rb +669 -0
  65. data/lib/tk/toplevel.rb +264 -0
  66. data/lib/tk/ttk_selector.rb +98 -0
  67. data/lib/tk/txtwin_abst.rb +39 -0
  68. data/lib/tk/validation.rb +397 -0
  69. data/lib/tk/variable.rb +1799 -0
  70. data/lib/tk/virtevent.rb +139 -0
  71. data/lib/tk/winfo.rb +392 -0
  72. data/lib/tk/winpkg.rb +156 -0
  73. data/lib/tk/wm.rb +552 -0
  74. data/lib/tk/xim.rb +122 -0
  75. data/lib/tkafter.rb +4 -0
  76. data/lib/tkbgerror.rb +4 -0
  77. data/lib/tkcanvas.rb +4 -0
  78. data/lib/tkclass.rb +47 -0
  79. data/lib/tkconsole.rb +4 -0
  80. data/lib/tkdialog.rb +4 -0
  81. data/lib/tkentry.rb +4 -0
  82. data/lib/tkextlib/ICONS.rb +13 -0
  83. data/lib/tkextlib/ICONS/icons.rb +129 -0
  84. data/lib/tkextlib/ICONS/setup.rb +8 -0
  85. data/lib/tkextlib/SUPPORT_STATUS +198 -0
  86. data/lib/tkextlib/blt.rb +189 -0
  87. data/lib/tkextlib/blt/barchart.rb +79 -0
  88. data/lib/tkextlib/blt/bitmap.rb +112 -0
  89. data/lib/tkextlib/blt/busy.rb +83 -0
  90. data/lib/tkextlib/blt/component.rb +2218 -0
  91. data/lib/tkextlib/blt/container.rb +28 -0
  92. data/lib/tkextlib/blt/cutbuffer.rb +23 -0
  93. data/lib/tkextlib/blt/dragdrop.rb +269 -0
  94. data/lib/tkextlib/blt/eps.rb +32 -0
  95. data/lib/tkextlib/blt/graph.rb +67 -0
  96. data/lib/tkextlib/blt/htext.rb +112 -0
  97. data/lib/tkextlib/blt/setup.rb +8 -0
  98. data/lib/tkextlib/blt/spline.rb +23 -0
  99. data/lib/tkextlib/blt/stripchart.rb +74 -0
  100. data/lib/tkextlib/blt/table.rb +412 -0
  101. data/lib/tkextlib/blt/tabnotebook.rb +110 -0
  102. data/lib/tkextlib/blt/tabset.rb +504 -0
  103. data/lib/tkextlib/blt/ted.rb +68 -0
  104. data/lib/tkextlib/blt/tile.rb +25 -0
  105. data/lib/tkextlib/blt/tile/button.rb +16 -0
  106. data/lib/tkextlib/blt/tile/checkbutton.rb +17 -0
  107. data/lib/tkextlib/blt/tile/frame.rb +16 -0
  108. data/lib/tkextlib/blt/tile/label.rb +16 -0
  109. data/lib/tkextlib/blt/tile/radiobutton.rb +17 -0
  110. data/lib/tkextlib/blt/tile/scrollbar.rb +16 -0
  111. data/lib/tkextlib/blt/tile/toplevel.rb +16 -0
  112. data/lib/tkextlib/blt/tree.rb +1058 -0
  113. data/lib/tkextlib/blt/treeview.rb +1287 -0
  114. data/lib/tkextlib/blt/unix_dnd.rb +141 -0
  115. data/lib/tkextlib/blt/vector.rb +256 -0
  116. data/lib/tkextlib/blt/watch.rb +175 -0
  117. data/lib/tkextlib/blt/win_printer.rb +61 -0
  118. data/lib/tkextlib/blt/winop.rb +107 -0
  119. data/lib/tkextlib/bwidget.rb +153 -0
  120. data/lib/tkextlib/bwidget/arrowbutton.rb +21 -0
  121. data/lib/tkextlib/bwidget/bitmap.rb +21 -0
  122. data/lib/tkextlib/bwidget/button.rb +31 -0
  123. data/lib/tkextlib/bwidget/buttonbox.rb +90 -0
  124. data/lib/tkextlib/bwidget/combobox.rb +62 -0
  125. data/lib/tkextlib/bwidget/dialog.rb +194 -0
  126. data/lib/tkextlib/bwidget/dragsite.rb +31 -0
  127. data/lib/tkextlib/bwidget/dropsite.rb +39 -0
  128. data/lib/tkextlib/bwidget/dynamichelp.rb +63 -0
  129. data/lib/tkextlib/bwidget/entry.rb +43 -0
  130. data/lib/tkextlib/bwidget/label.rb +41 -0
  131. data/lib/tkextlib/bwidget/labelentry.rb +80 -0
  132. data/lib/tkextlib/bwidget/labelframe.rb +52 -0
  133. data/lib/tkextlib/bwidget/listbox.rb +361 -0
  134. data/lib/tkextlib/bwidget/mainframe.rb +132 -0
  135. data/lib/tkextlib/bwidget/messagedlg.rb +192 -0
  136. data/lib/tkextlib/bwidget/notebook.rb +166 -0
  137. data/lib/tkextlib/bwidget/pagesmanager.rb +73 -0
  138. data/lib/tkextlib/bwidget/panedwindow.rb +42 -0
  139. data/lib/tkextlib/bwidget/panelframe.rb +67 -0
  140. data/lib/tkextlib/bwidget/passwddlg.rb +44 -0
  141. data/lib/tkextlib/bwidget/progressbar.rb +20 -0
  142. data/lib/tkextlib/bwidget/progressdlg.rb +58 -0
  143. data/lib/tkextlib/bwidget/scrollableframe.rb +40 -0
  144. data/lib/tkextlib/bwidget/scrolledwindow.rb +48 -0
  145. data/lib/tkextlib/bwidget/scrollview.rb +25 -0
  146. data/lib/tkextlib/bwidget/selectcolor.rb +73 -0
  147. data/lib/tkextlib/bwidget/selectfont.rb +91 -0
  148. data/lib/tkextlib/bwidget/separator.rb +20 -0
  149. data/lib/tkextlib/bwidget/setup.rb +8 -0
  150. data/lib/tkextlib/bwidget/spinbox.rb +98 -0
  151. data/lib/tkextlib/bwidget/statusbar.rb +62 -0
  152. data/lib/tkextlib/bwidget/titleframe.rb +33 -0
  153. data/lib/tkextlib/bwidget/tree.rb +500 -0
  154. data/lib/tkextlib/bwidget/widget.rb +129 -0
  155. data/lib/tkextlib/itcl.rb +13 -0
  156. data/lib/tkextlib/itcl/incr_tcl.rb +178 -0
  157. data/lib/tkextlib/itcl/setup.rb +13 -0
  158. data/lib/tkextlib/itk.rb +13 -0
  159. data/lib/tkextlib/itk/incr_tk.rb +446 -0
  160. data/lib/tkextlib/itk/setup.rb +13 -0
  161. data/lib/tkextlib/iwidgets.rb +94 -0
  162. data/lib/tkextlib/iwidgets/buttonbox.rb +121 -0
  163. data/lib/tkextlib/iwidgets/calendar.rb +125 -0
  164. data/lib/tkextlib/iwidgets/canvasprintbox.rb +53 -0
  165. data/lib/tkextlib/iwidgets/canvasprintdialog.rb +38 -0
  166. data/lib/tkextlib/iwidgets/checkbox.rb +130 -0
  167. data/lib/tkextlib/iwidgets/combobox.rb +104 -0
  168. data/lib/tkextlib/iwidgets/dateentry.rb +20 -0
  169. data/lib/tkextlib/iwidgets/datefield.rb +58 -0
  170. data/lib/tkextlib/iwidgets/dialog.rb +20 -0
  171. data/lib/tkextlib/iwidgets/dialogshell.rb +121 -0
  172. data/lib/tkextlib/iwidgets/disjointlistbox.rb +50 -0
  173. data/lib/tkextlib/iwidgets/entryfield.rb +185 -0
  174. data/lib/tkextlib/iwidgets/extbutton.rb +40 -0
  175. data/lib/tkextlib/iwidgets/extfileselectionbox.rb +46 -0
  176. data/lib/tkextlib/iwidgets/extfileselectiondialog.rb +33 -0
  177. data/lib/tkextlib/iwidgets/feedback.rb +35 -0
  178. data/lib/tkextlib/iwidgets/fileselectionbox.rb +46 -0
  179. data/lib/tkextlib/iwidgets/fileselectiondialog.rb +33 -0
  180. data/lib/tkextlib/iwidgets/finddialog.rb +42 -0
  181. data/lib/tkextlib/iwidgets/hierarchy.rb +365 -0
  182. data/lib/tkextlib/iwidgets/hyperhelp.rb +50 -0
  183. data/lib/tkextlib/iwidgets/labeledframe.rb +39 -0
  184. data/lib/tkextlib/iwidgets/labeledwidget.rb +45 -0
  185. data/lib/tkextlib/iwidgets/mainwindow.rb +67 -0
  186. data/lib/tkextlib/iwidgets/menubar.rb +212 -0
  187. data/lib/tkextlib/iwidgets/messagebox.rb +93 -0
  188. data/lib/tkextlib/iwidgets/messagedialog.rb +20 -0
  189. data/lib/tkextlib/iwidgets/notebook.rb +175 -0
  190. data/lib/tkextlib/iwidgets/optionmenu.rb +92 -0
  191. data/lib/tkextlib/iwidgets/panedwindow.rb +134 -0
  192. data/lib/tkextlib/iwidgets/promptdialog.rb +131 -0
  193. data/lib/tkextlib/iwidgets/pushbutton.rb +35 -0
  194. data/lib/tkextlib/iwidgets/radiobox.rb +121 -0
  195. data/lib/tkextlib/iwidgets/scopedobject.rb +24 -0
  196. data/lib/tkextlib/iwidgets/scrolledcanvas.rb +353 -0
  197. data/lib/tkextlib/iwidgets/scrolledframe.rb +59 -0
  198. data/lib/tkextlib/iwidgets/scrolledhtml.rb +58 -0
  199. data/lib/tkextlib/iwidgets/scrolledlistbox.rb +207 -0
  200. data/lib/tkextlib/iwidgets/scrolledtext.rb +568 -0
  201. data/lib/tkextlib/iwidgets/scrolledwidget.rb +20 -0
  202. data/lib/tkextlib/iwidgets/selectionbox.rb +102 -0
  203. data/lib/tkextlib/iwidgets/selectiondialog.rb +92 -0
  204. data/lib/tkextlib/iwidgets/setup.rb +8 -0
  205. data/lib/tkextlib/iwidgets/shell.rb +38 -0
  206. data/lib/tkextlib/iwidgets/spindate.rb +48 -0
  207. data/lib/tkextlib/iwidgets/spinint.rb +30 -0
  208. data/lib/tkextlib/iwidgets/spinner.rb +169 -0
  209. data/lib/tkextlib/iwidgets/spintime.rb +48 -0
  210. data/lib/tkextlib/iwidgets/tabnotebook.rb +181 -0
  211. data/lib/tkextlib/iwidgets/tabset.rb +145 -0
  212. data/lib/tkextlib/iwidgets/timeentry.rb +25 -0
  213. data/lib/tkextlib/iwidgets/timefield.rb +58 -0
  214. data/lib/tkextlib/iwidgets/toolbar.rb +112 -0
  215. data/lib/tkextlib/iwidgets/watch.rb +56 -0
  216. data/lib/tkextlib/pkg_checker.rb +184 -0
  217. data/lib/tkextlib/setup.rb +8 -0
  218. data/lib/tkextlib/tcllib.rb +105 -0
  219. data/lib/tkextlib/tcllib/autoscroll.rb +158 -0
  220. data/lib/tkextlib/tcllib/ctext.rb +160 -0
  221. data/lib/tkextlib/tcllib/cursor.rb +97 -0
  222. data/lib/tkextlib/tcllib/datefield.rb +57 -0
  223. data/lib/tkextlib/tcllib/dialog.rb +84 -0
  224. data/lib/tkextlib/tcllib/getstring.rb +134 -0
  225. data/lib/tkextlib/tcllib/history.rb +73 -0
  226. data/lib/tkextlib/tcllib/ico.rb +146 -0
  227. data/lib/tkextlib/tcllib/ip_entry.rb +75 -0
  228. data/lib/tkextlib/tcllib/panelframe.rb +78 -0
  229. data/lib/tkextlib/tcllib/plotchart.rb +1404 -0
  230. data/lib/tkextlib/tcllib/ruler.rb +65 -0
  231. data/lib/tkextlib/tcllib/screenruler.rb +68 -0
  232. data/lib/tkextlib/tcllib/scrollwin.rb +61 -0
  233. data/lib/tkextlib/tcllib/setup.rb +8 -0
  234. data/lib/tkextlib/tcllib/style.rb +61 -0
  235. data/lib/tkextlib/tcllib/superframe.rb +51 -0
  236. data/lib/tkextlib/tcllib/swaplist.rb +150 -0
  237. data/lib/tkextlib/tcllib/tablelist.rb +28 -0
  238. data/lib/tkextlib/tcllib/tablelist_core.rb +1072 -0
  239. data/lib/tkextlib/tcllib/tablelist_tile.rb +43 -0
  240. data/lib/tkextlib/tcllib/tkpiechart.rb +314 -0
  241. data/lib/tkextlib/tcllib/tooltip.rb +104 -0
  242. data/lib/tkextlib/tcllib/widget.rb +82 -0
  243. data/lib/tkextlib/tclx.rb +13 -0
  244. data/lib/tkextlib/tclx/setup.rb +8 -0
  245. data/lib/tkextlib/tclx/tclx.rb +74 -0
  246. data/lib/tkextlib/tile.rb +449 -0
  247. data/lib/tkextlib/tile/dialog.rb +102 -0
  248. data/lib/tkextlib/tile/setup.rb +8 -0
  249. data/lib/tkextlib/tile/sizegrip.rb +32 -0
  250. data/lib/tkextlib/tile/style.rb +336 -0
  251. data/lib/tkextlib/tile/tbutton.rb +34 -0
  252. data/lib/tkextlib/tile/tcheckbutton.rb +38 -0
  253. data/lib/tkextlib/tile/tcombobox.rb +55 -0
  254. data/lib/tkextlib/tile/tentry.rb +49 -0
  255. data/lib/tkextlib/tile/tframe.rb +34 -0
  256. data/lib/tkextlib/tile/tlabel.rb +34 -0
  257. data/lib/tkextlib/tile/tlabelframe.rb +38 -0
  258. data/lib/tkextlib/tile/tmenubutton.rb +38 -0
  259. data/lib/tkextlib/tile/tnotebook.rb +147 -0
  260. data/lib/tkextlib/tile/tpaned.rb +245 -0
  261. data/lib/tkextlib/tile/tprogressbar.rb +57 -0
  262. data/lib/tkextlib/tile/tradiobutton.rb +38 -0
  263. data/lib/tkextlib/tile/treeview.rb +1306 -0
  264. data/lib/tkextlib/tile/tscale.rb +56 -0
  265. data/lib/tkextlib/tile/tscrollbar.rb +63 -0
  266. data/lib/tkextlib/tile/tseparator.rb +34 -0
  267. data/lib/tkextlib/tile/tsquare.rb +30 -0
  268. data/lib/tkextlib/tkDND.rb +18 -0
  269. data/lib/tkextlib/tkDND/setup.rb +8 -0
  270. data/lib/tkextlib/tkDND/shape.rb +125 -0
  271. data/lib/tkextlib/tkDND/tkdnd.rb +182 -0
  272. data/lib/tkextlib/tkHTML.rb +13 -0
  273. data/lib/tkextlib/tkHTML/htmlwidget.rb +453 -0
  274. data/lib/tkextlib/tkHTML/setup.rb +8 -0
  275. data/lib/tkextlib/tkimg.rb +36 -0
  276. data/lib/tkextlib/tkimg/bmp.rb +33 -0
  277. data/lib/tkextlib/tkimg/gif.rb +33 -0
  278. data/lib/tkextlib/tkimg/ico.rb +33 -0
  279. data/lib/tkextlib/tkimg/jpeg.rb +33 -0
  280. data/lib/tkextlib/tkimg/pcx.rb +33 -0
  281. data/lib/tkextlib/tkimg/pixmap.rb +44 -0
  282. data/lib/tkextlib/tkimg/png.rb +33 -0
  283. data/lib/tkextlib/tkimg/ppm.rb +33 -0
  284. data/lib/tkextlib/tkimg/ps.rb +33 -0
  285. data/lib/tkextlib/tkimg/setup.rb +8 -0
  286. data/lib/tkextlib/tkimg/sgi.rb +33 -0
  287. data/lib/tkextlib/tkimg/sun.rb +33 -0
  288. data/lib/tkextlib/tkimg/tga.rb +33 -0
  289. data/lib/tkextlib/tkimg/tiff.rb +33 -0
  290. data/lib/tkextlib/tkimg/window.rb +33 -0
  291. data/lib/tkextlib/tkimg/xbm.rb +33 -0
  292. data/lib/tkextlib/tkimg/xpm.rb +33 -0
  293. data/lib/tkextlib/tktable.rb +14 -0
  294. data/lib/tkextlib/tktable/setup.rb +8 -0
  295. data/lib/tkextlib/tktable/tktable.rb +966 -0
  296. data/lib/tkextlib/tktrans.rb +14 -0
  297. data/lib/tkextlib/tktrans/setup.rb +8 -0
  298. data/lib/tkextlib/tktrans/tktrans.rb +64 -0
  299. data/lib/tkextlib/treectrl.rb +13 -0
  300. data/lib/tkextlib/treectrl/setup.rb +8 -0
  301. data/lib/tkextlib/treectrl/tktreectrl.rb +2522 -0
  302. data/lib/tkextlib/trofs.rb +13 -0
  303. data/lib/tkextlib/trofs/setup.rb +8 -0
  304. data/lib/tkextlib/trofs/trofs.rb +51 -0
  305. data/lib/tkextlib/version.rb +6 -0
  306. data/lib/tkextlib/vu.rb +48 -0
  307. data/lib/tkextlib/vu/bargraph.rb +61 -0
  308. data/lib/tkextlib/vu/charts.rb +53 -0
  309. data/lib/tkextlib/vu/dial.rb +102 -0
  310. data/lib/tkextlib/vu/pie.rb +286 -0
  311. data/lib/tkextlib/vu/setup.rb +8 -0
  312. data/lib/tkextlib/vu/spinbox.rb +22 -0
  313. data/lib/tkextlib/winico.rb +14 -0
  314. data/lib/tkextlib/winico/setup.rb +8 -0
  315. data/lib/tkextlib/winico/winico.rb +224 -0
  316. data/lib/tkfont.rb +4 -0
  317. data/lib/tkmacpkg.rb +4 -0
  318. data/lib/tkmenubar.rb +4 -0
  319. data/lib/tkmngfocus.rb +4 -0
  320. data/lib/tkpalette.rb +4 -0
  321. data/lib/tkscrollbox.rb +4 -0
  322. data/lib/tktext.rb +4 -0
  323. data/lib/tkvirtevent.rb +4 -0
  324. data/lib/tkwinpkg.rb +4 -0
  325. data/spec/spec.opts +1 -0
  326. data/spec/spec_helper.rb +9 -0
  327. data/spec/tk-win_spec.rb +7 -0
  328. data/tk-win.gemspec +373 -0
  329. metadata +412 -0
@@ -0,0 +1,14 @@
1
+ #
2
+ # TkTrans support (win32 only)
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+ require 'tk'
6
+
7
+ # call setup script for general 'tkextlib' libraries
8
+ require 'tkextlib/setup.rb'
9
+
10
+ # call setup script
11
+ require 'tkextlib/tktrans/setup.rb'
12
+
13
+ # load library
14
+ require 'tkextlib/tktrans/tktrans'
@@ -0,0 +1,8 @@
1
+ #
2
+ # setup.rb -- setup script before calling TkPackage.require()
3
+ #
4
+ # If you need some setup operations (for example, add a library path
5
+ # to the library search path) before using Tcl/Tk library packages
6
+ # wrapped by Ruby scripts in this directory, please write the setup
7
+ # operations in this file.
8
+ #
@@ -0,0 +1,64 @@
1
+ #
2
+ # TkTrans support (win32 only)
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+ require 'tk'
6
+
7
+ # call setup script for general 'tkextlib' libraries
8
+ require 'tkextlib/setup.rb'
9
+
10
+ # call setup script
11
+ require 'tkextlib/tktrans/setup.rb'
12
+
13
+ TkPackage.require('tktrans') rescue Tk.load_tcllibrary('tktrans')
14
+
15
+ module Tk
16
+ module TkTrans
17
+ PACKAGE_NAME = 'tktrans'.freeze
18
+ def self.package_name
19
+ PACKAGE_NAME
20
+ end
21
+
22
+ def self.package_version
23
+ begin
24
+ TkPackage.require('tktrans')
25
+ rescue
26
+ ''
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ class TkWindow
33
+ def tktrans_set_image(img)
34
+ tk_send('tktrans::setwidget', @path, img)
35
+ self
36
+ end
37
+ def tktrans_get_image()
38
+ tk_send('tktrans::setwidget', @path)
39
+ end
40
+ end
41
+
42
+ class Tk::Root
43
+ undef tktrans_set_image, tktrans_get_image
44
+
45
+ def tktrans_set_image(img)
46
+ tk_send('tktrans::settoplevel', @path, img)
47
+ self
48
+ end
49
+ def tktrans_get_image()
50
+ tk_send('tktrans::settoplevel', @path)
51
+ end
52
+ end
53
+
54
+ class Tk::Toplevel
55
+ undef tktrans_set_image, tktrans_get_image
56
+
57
+ def tktrans_set_image(img)
58
+ tk_send('tktrans::settoplevel', @path, img)
59
+ self
60
+ end
61
+ def tktrans_get_image()
62
+ tk_send('tktrans::settoplevel', @path)
63
+ end
64
+ end
@@ -0,0 +1,13 @@
1
+ #
2
+ # TkTreeCtrl support
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+
6
+ # call setup script for general 'tkextlib' libraries
7
+ require 'tkextlib/setup.rb'
8
+
9
+ # call setup script
10
+ require 'tkextlib/treectrl/setup.rb'
11
+
12
+ # load library
13
+ require 'tkextlib/treectrl/tktreectrl'
@@ -0,0 +1,8 @@
1
+ #
2
+ # setup.rb -- setup script before calling TkPackage.require()
3
+ #
4
+ # If you need some setup operations (for example, add a library path
5
+ # to the library search path) before using Tcl/Tk library packages
6
+ # wrapped by Ruby scripts in this directory, please write the setup
7
+ # operations in this file.
8
+ #
@@ -0,0 +1,2522 @@
1
+ #
2
+ # tkextlib/treectrl/tktreectrl.rb
3
+ # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4
+ #
5
+
6
+ require 'tk'
7
+
8
+ # call setup script for general 'tkextlib' libraries
9
+ require 'tkextlib/setup.rb'
10
+
11
+ # call setup script
12
+ require 'tkextlib/treectrl/setup.rb'
13
+
14
+ # TkPackage.require('treectrl', '1.0')
15
+ # TkPackage.require('treectrl', '1.1')
16
+ TkPackage.require('treectrl')
17
+
18
+ module Tk
19
+ class TreeCtrl < TkWindow
20
+ BindTag_FileList = TkBindTag.new_by_name('TreeCtrlFileList')
21
+
22
+ PACKAGE_NAME = 'treectrl'.freeze
23
+ def self.package_name
24
+ PACKAGE_NAME
25
+ end
26
+
27
+ def self.package_version
28
+ begin
29
+ TkPackage.require('treectrl')
30
+ rescue
31
+ ''
32
+ end
33
+ end
34
+
35
+ HasColumnCreateCommand =
36
+ (TkPackage.vcompare(self.package_version, '1.1') >= 0)
37
+
38
+ # dummy ::
39
+ # pkgIndex.tcl of TreeCtrl-1.0 doesn't support auto_load for
40
+ # 'loupe' command (probably it is bug, I think).
41
+ # So, calling a 'treectrl' command for loading the dll with
42
+ # the auto_load facility.
43
+ begin
44
+ tk_call('treectrl')
45
+ rescue
46
+ end
47
+ def self.loupe(img, x, y, w, h, zoom)
48
+ # NOTE: platform == 'unix' only
49
+
50
+ # img => TkPhotoImage
51
+ # x, y => screen coords
52
+ # w, h => magnifier width and height
53
+ # zoom => zooming rate
54
+ Tk.tk_call_without_enc('loupe', img, x, y, w, h, zoom)
55
+ end
56
+
57
+ def self.text_layout(font, text, keys={})
58
+ TkComm.list(Tk.tk_call_without_enc('textlayout', font, text, keys))
59
+ end
60
+
61
+ def self.image_tint(img, color, alpha)
62
+ Tk.tk_call_without_enc('imagetint', img, color, alpha)
63
+ end
64
+
65
+ class NotifyEvent < TkUtil::CallbackSubst
66
+ end
67
+
68
+ module ConfigMethod
69
+ end
70
+ end
71
+ TreeCtrl_Widget = TreeCtrl
72
+ end
73
+
74
+ ##############################################
75
+
76
+ class Tk::TreeCtrl::NotifyEvent
77
+ # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
78
+ KEY_TBL = [
79
+ [ ?c, ?n, :item_num ],
80
+ [ ?d, ?s, :detail ],
81
+ [ ?D, ?l, :items ],
82
+ [ ?e, ?e, :event ],
83
+ [ ?I, ?n, :id ],
84
+ [ ?l, ?n, :lower_bound ],
85
+ [ ?p, ?n, :active_id ],
86
+ [ ?P, ?e, :pattern ],
87
+ [ ?S, ?l, :sel_items ],
88
+ [ ?T, ?w, :widget ],
89
+ [ ?u, ?n, :upper_bound ],
90
+ [ ?W, ?o, :object ],
91
+ [ ??, ?x, :parm_info ],
92
+ nil
93
+ ]
94
+
95
+ # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
96
+ PROC_TBL = [
97
+ [ ?n, TkComm.method(:num_or_str) ],
98
+ [ ?s, TkComm.method(:string) ],
99
+ [ ?l, TkComm.method(:list) ],
100
+ [ ?w, TkComm.method(:window) ],
101
+
102
+ [ ?e, proc{|val|
103
+ case val
104
+ when /^<<[^<>]+>>$/
105
+ TkVirtualEvent.getobj(val[1..-2])
106
+ when /^<[^<>]+>$/
107
+ val[1..-2]
108
+ else
109
+ val
110
+ end
111
+ }
112
+ ],
113
+
114
+ [ ?o, proc{|val| TkComm.tk_tcl2ruby(val)} ],
115
+
116
+ [ ?x, proc{|val|
117
+ begin
118
+ inf = {}
119
+ Hash[*(TkComm.list(val))].each{|k, v|
120
+ if keyinfo = KEY_TBL.assoc(k[0])
121
+ if cmd = PROC_TBL.assoc(keyinfo[1])
122
+ begin
123
+ new_v = cmd.call(v)
124
+ v = new_v
125
+ rescue
126
+ end
127
+ end
128
+ end
129
+ inf[k] = v
130
+ }
131
+ inf
132
+ rescue
133
+ val
134
+ end
135
+ } ],
136
+
137
+ nil
138
+ ]
139
+
140
+ =begin
141
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
142
+ KEY_TBL.map!{|inf|
143
+ if inf.kind_of?(Array)
144
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
145
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
146
+ end
147
+ inf
148
+ }
149
+
150
+ PROC_TBL.map!{|inf|
151
+ if inf.kind_of?(Array)
152
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
153
+ end
154
+ inf
155
+ }
156
+ =end
157
+
158
+ # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
159
+ #
160
+ # _get_subst_key() and _get_all_subst_keys() generates key-string
161
+ # which describe how to convert callback arguments to ruby objects.
162
+ # When binding parameters are given, use _get_subst_key().
163
+ # But when no parameters are given, use _get_all_subst_keys() to
164
+ # create a Event class object as a callback parameter.
165
+ #
166
+ # scan_args() is used when doing callback. It convert arguments
167
+ # ( which are Tcl strings ) to ruby objects based on the key string
168
+ # that is generated by _get_subst_key() or _get_all_subst_keys().
169
+ #
170
+ _setup_subst_table(KEY_TBL, PROC_TBL);
171
+ end
172
+
173
+ ##############################################
174
+
175
+ module Tk::TreeCtrl::ConfigMethod
176
+ include TkItemConfigMethod
177
+
178
+ def treectrl_tagid(key, obj)
179
+ if key.kind_of?(Array)
180
+ key = key.join(' ')
181
+ else
182
+ key = key.to_s
183
+ end
184
+
185
+ if (obj.kind_of?(Tk::TreeCtrl::Column) ||
186
+ obj.kind_of?(Tk::TreeCtrl::Element) ||
187
+ obj.kind_of?(Tk::TreeCtrl::Item) ||
188
+ obj.kind_of?(Tk::TreeCtrl::Style))
189
+ obj = obj.id
190
+ end
191
+
192
+ case key
193
+ when 'column'
194
+ obj
195
+
196
+ when 'debug'
197
+ None
198
+
199
+ when 'dragimage'
200
+ None
201
+
202
+ when 'element'
203
+ obj
204
+
205
+ when 'item element'
206
+ obj
207
+
208
+ when 'marquee'
209
+ None
210
+
211
+ when 'notify'
212
+ obj
213
+
214
+ when 'style'
215
+ obj
216
+
217
+ else
218
+ obj
219
+ end
220
+ end
221
+
222
+ def tagid(mixed_id)
223
+ if mixed_id == 'debug'
224
+ ['debug', None]
225
+ elsif mixed_id == 'dragimage'
226
+ ['dragimage', None]
227
+ elsif mixed_id == 'marquee'
228
+ ['marquee', None]
229
+ elsif mixed_id.kind_of?(Array)
230
+ [mixed_id[0], treectrl_tagid(*mixed_id)]
231
+ else
232
+ tagid(mixed_id.split(':'))
233
+ end
234
+ end
235
+
236
+ def __item_cget_cmd(mixed_id)
237
+ if mixed_id[0] == 'column' && mixed_id[1] == 'drag'
238
+ return [self.path, 'column', 'dragcget']
239
+ end
240
+
241
+ if mixed_id[1].kind_of?(Array)
242
+ id = mixed_id[1]
243
+ else
244
+ id = [mixed_id[1]]
245
+ end
246
+
247
+ if mixed_id[0].kind_of?(Array)
248
+ ([self.path].concat(mixed_id[0]) << 'cget').concat(id)
249
+ else
250
+ [self.path, mixed_id[0], 'cget'].concat(id)
251
+ end
252
+ end
253
+ private :__item_cget_cmd
254
+
255
+ def __item_config_cmd(mixed_id)
256
+ if mixed_id[0] == 'column' && mixed_id[1] == 'drag'
257
+ return [self.path, 'column', 'dragconfigure']
258
+ end
259
+
260
+ if mixed_id[1].kind_of?(Array)
261
+ id = mixed_id[1]
262
+ else
263
+ id = [mixed_id[1]]
264
+ end
265
+
266
+ if mixed_id[0].kind_of?(Array)
267
+ ([self.path].concat(mixed_id[0]) << 'configure').concat(id)
268
+ else
269
+ [self.path, mixed_id[0], 'configure'].concat(id)
270
+ end
271
+ end
272
+ private :__item_config_cmd
273
+
274
+ def __item_pathname(id)
275
+ if id.kind_of?(Array)
276
+ key = id[0]
277
+ if key.kind_of?(Array)
278
+ key = key.join(' ')
279
+ end
280
+
281
+ tag = id[1]
282
+ if tag.kind_of?(Array)
283
+ tag = tag.join(' ')
284
+ end
285
+
286
+ id = [key, tag].join(':')
287
+ end
288
+ [self.path, id].join(';')
289
+ end
290
+ private :__item_pathname
291
+
292
+ def __item_configinfo_struct(id)
293
+ if id.kind_of?(Array) && id[0].to_s == 'notify'
294
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
295
+ :default_value=>nil, :current_value=>1}
296
+ else
297
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
298
+ :default_value=>3, :current_value=>4}
299
+ end
300
+ end
301
+ private :__item_configinfo_struct
302
+
303
+
304
+ def __item_font_optkeys(id)
305
+ if id.kind_of?(Array) && (id[0] == 'element' ||
306
+ (id[0].kind_of?(Array) && id[0][1] == 'element'))
307
+ []
308
+ else
309
+ ['font']
310
+ end
311
+ end
312
+ private :__item_font_optkeys
313
+
314
+ def __item_numstrval_optkeys(id)
315
+ if id == 'debug'
316
+ ['displaydelay']
317
+ else
318
+ super(id)
319
+ end
320
+ end
321
+ private :__item_numstrval_optkeys
322
+
323
+ def __item_boolval_optkeys(id)
324
+ if id == 'debug'
325
+ ['data', 'display', 'enable', 'span', 'textlayout']
326
+ elsif id == 'dragimage'
327
+ ['visible']
328
+ elsif id == 'marquee'
329
+ ['visible']
330
+ elsif id.kind_of?(Array)
331
+ case id[0]
332
+ when 'item'
333
+ ['visible', 'wrap', 'open', 'returnid', 'visible']
334
+ when 'column'
335
+ if id[1] == 'drag'
336
+ ['enable']
337
+ else
338
+ ['button', 'expand', 'resize', 'squeeze', 'sunken',
339
+ 'visible', 'widthhack']
340
+ end
341
+ when 'element'
342
+ ['draw', 'filled', 'showfocus', 'clip', 'destroy']
343
+ when 'notify'
344
+ ['active']
345
+ when 'style'
346
+ ['detach', 'indent', 'visible']
347
+ else
348
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
349
+ ['filled', 'showfocus']
350
+ else
351
+ super(id)
352
+ end
353
+ end
354
+ else
355
+ super(id)
356
+ end
357
+ end
358
+ private :__item_boolval_optkeys
359
+
360
+ def __item_strval_optkeys(id)
361
+ if id == 'debug'
362
+ ['erasecolor']
363
+ elsif id.kind_of?(Array)
364
+ case id[0]
365
+ when 'column'
366
+ if id[1] == 'drag'
367
+ ['indicatorcolor']
368
+ else
369
+ super(id) << 'textcolor'
370
+ end
371
+ when 'element'
372
+ super(id) << 'fill' << 'outline' << 'format'
373
+ else
374
+ super(id)
375
+ end
376
+ else
377
+ super(id)
378
+ end
379
+ end
380
+ private :__item_strval_optkeys
381
+
382
+ def __item_listval_optkeys(id)
383
+ if id.kind_of?(Array)
384
+ case id[0]
385
+ when 'column'
386
+ ['itembackground']
387
+ when 'element'
388
+ ['relief']
389
+ when 'style'
390
+ ['union']
391
+ else
392
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
393
+ ['relief']
394
+ else
395
+ []
396
+ end
397
+ end
398
+ else
399
+ []
400
+ end
401
+ end
402
+ private :__item_listval_optkeys
403
+
404
+ def __item_val2ruby_optkeys(id)
405
+ if id.kind_of?(Array)
406
+ case id[0]
407
+ when 'item'
408
+ { 'button' => proc{|id,val| (val == 'auto')? val: TkComm.bool(val)} }
409
+ else
410
+ []
411
+ end
412
+ else
413
+ []
414
+ end
415
+ end
416
+ private :__item_val2ruby_optkeys
417
+
418
+ def __item_keyonly_optkeys(id) # { def_key=>(undef_key|nil), ... }
419
+ {
420
+ 'notreally'=>nil,
421
+ 'increasing'=>'decreasing',
422
+ 'decreasing'=>'increasing',
423
+ 'ascii'=>nil,
424
+ 'dictionary'=>nil,
425
+ 'integer'=>nil,
426
+ 'real'=>nil
427
+ }
428
+ end
429
+ private :__item_keyonly_optkeys
430
+
431
+ def column_cget_tkstring(tagOrId, option)
432
+ itemcget_tkstring(['column', tagOrId], option)
433
+ end
434
+ def column_cget(tagOrId, option)
435
+ itemcget(['column', tagOrId], option)
436
+ end
437
+ def column_cget_strict(tagOrId, option)
438
+ itemcget_strict(['column', tagOrId], option)
439
+ end
440
+ def column_configure(tagOrId, slot, value=None)
441
+ itemconfigure(['column', tagOrId], slot, value)
442
+ end
443
+ def column_configinfo(tagOrId, slot=nil)
444
+ itemconfiginfo(['column', tagOrId], slot)
445
+ end
446
+ def current_column_configinfo(tagOrId, slot=nil)
447
+ current_itemconfiginfo(['column', tagOrId], slot)
448
+ end
449
+
450
+ def column_dragcget_tkstring(option)
451
+ itemcget_tkstring(['column', 'drag'], option)
452
+ end
453
+ def column_dragcget(option)
454
+ itemcget(['column', 'drag'], option)
455
+ end
456
+ def column_dragcget_strict(option)
457
+ itemcget_strict(['column', 'drag'], option)
458
+ end
459
+ def column_dragconfigure(slot, value=None)
460
+ itemconfigure(['column', 'drag'], slot, value)
461
+ end
462
+ def column_dragconfiginfo(slot=nil)
463
+ itemconfiginfo(['column', 'drag'], slot)
464
+ end
465
+ def current_column_dragconfiginfo(slot=nil)
466
+ current_itemconfiginfo(['column', 'drag'], slot)
467
+ end
468
+
469
+ def debug_cget_tkstring(option)
470
+ itemcget_tkstring('debug', option)
471
+ end
472
+ def debug_cget(option)
473
+ itemcget('debug', option)
474
+ end
475
+ def debug_cget_strict(option)
476
+ itemcget_strict('debug', option)
477
+ end
478
+ def debug_configure(slot, value=None)
479
+ itemconfigure('debug', slot, value)
480
+ end
481
+ def debug_configinfo(slot=nil)
482
+ itemconfiginfo('debug', slot)
483
+ end
484
+ def current_debug_configinfo(slot=nil)
485
+ current_itemconfiginfo('debug', slot)
486
+ end
487
+
488
+ def dragimage_cget_tkstring(option)
489
+ itemcget_tkstring('dragimage', option)
490
+ end
491
+ def dragimage_cget(option)
492
+ itemcget('dragimage', option)
493
+ end
494
+ def dragimage_cget_strict(option)
495
+ itemcget_strict('dragimage', option)
496
+ end
497
+ def dragimage_configure(slot, value=None)
498
+ itemconfigure('dragimage', slot, value)
499
+ end
500
+ def dragimage_configinfo(slot=nil)
501
+ itemconfiginfo('dragimage', slot)
502
+ end
503
+ def current_dragimage_configinfo(slot=nil)
504
+ current_itemconfiginfo('dragimage', slot)
505
+ end
506
+
507
+ def element_cget_tkstring(tagOrId, option)
508
+ itemcget_tkstring(['element', tagOrId], option)
509
+ end
510
+ def element_cget(tagOrId, option)
511
+ itemcget(['element', tagOrId], option)
512
+ end
513
+ def element_cget_strict(tagOrId, option)
514
+ itemcget_strict(['element', tagOrId], option)
515
+ end
516
+ def element_configure(tagOrId, slot, value=None)
517
+ itemconfigure(['element', tagOrId], slot, value)
518
+ end
519
+ def element_configinfo(tagOrId, slot=nil)
520
+ itemconfiginfo(['element', tagOrId], slot)
521
+ end
522
+ def current_element_configinfo(tagOrId, slot=nil)
523
+ current_itemconfiginfo(['element', tagOrId], slot)
524
+ end
525
+
526
+ def item_cget_tkstring(tagOrId, option)
527
+ itemcget_tkstring(['item', tagOrId], option)
528
+ end
529
+ def item_cget(tagOrId, option)
530
+ itemcget(['item', tagOrId], option)
531
+ end
532
+ def item_cget_strict(tagOrId, option)
533
+ itemcget_strict(['item', tagOrId], option)
534
+ end
535
+ def item_configure(tagOrId, slot, value=None)
536
+ itemconfigure(['item', tagOrId], slot, value)
537
+ end
538
+ def item_configinfo(tagOrId, slot=nil)
539
+ itemconfiginfo(['item', tagOrId], slot)
540
+ end
541
+ def current_item_configinfo(tagOrId, slot=nil)
542
+ current_itemconfiginfo(['item', tagOrId], slot)
543
+ end
544
+
545
+ def item_element_cget_tkstring(item, column, elem, option)
546
+ itemcget_tkstring([['item', 'element'], [item, column, elem]], option)
547
+ end
548
+ def item_element_cget(item, column, elem, option)
549
+ itemcget([['item', 'element'], [item, column, elem]], option)
550
+ end
551
+ def item_element_cget_strict(item, column, elem, option)
552
+ itemcget_strict([['item', 'element'], [item, column, elem]], option)
553
+ end
554
+ def item_element_configure(item, column, elem, slot, value=None)
555
+ itemconfigure([['item', 'element'], [item, column, elem]], slot, value)
556
+ end
557
+ def item_element_configinfo(item, column, elem, slot=nil)
558
+ itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
559
+ end
560
+ def current_item_element_configinfo(item, column, elem, slot=nil)
561
+ current_itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
562
+ end
563
+
564
+ def marquee_cget_tkstring(option)
565
+ itemcget_tkstring('marquee', option)
566
+ end
567
+ def marquee_cget(option)
568
+ itemcget('marquee', option)
569
+ end
570
+ def marquee_cget_strict(option)
571
+ itemcget_strict('marquee', option)
572
+ end
573
+ def marquee_configure(slot, value=None)
574
+ itemconfigure('marquee', slot, value)
575
+ end
576
+ def marquee_configinfo(slot=nil)
577
+ itemconfiginfo('marquee', slot)
578
+ end
579
+ def current_marquee_configinfo(slot=nil)
580
+ current_itemconfiginfo('marquee', slot)
581
+ end
582
+
583
+ def notify_cget_tkstring(win, pattern, option)
584
+ pattern = "<#{pattern}>"
585
+ # "notify" doesn't have cget subcommand.
586
+ tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(['notify', [win, pattern]])) << "-#{option}")), false, true)[-1]
587
+ end
588
+ def notify_cget(win, pattern, option)
589
+ pattern = "<#{pattern}>"
590
+ # "notify" doesn't have cget subcommand.
591
+ current_itemconfiginfo(['notify', [win, pattern]])[option.to_s]
592
+ end
593
+ def notify_cget_strict(win, pattern, option)
594
+ pattern = "<#{pattern}>"
595
+ # "notify" doesn't have cget subcommand.
596
+ info = current_itemconfiginfo(['notify', [win, pattern]])
597
+ option = option.to_s
598
+ unless info.has_key?(option)
599
+ fail RuntimeError, "unknown option \"#{option}\""
600
+ else
601
+ info[option]
602
+ end
603
+ end
604
+ def notify_configure(win, pattern, slot, value=None)
605
+ pattern = "<#{pattern}>"
606
+ itemconfigure(['notify', [win, pattern]], slot, value)
607
+ end
608
+ def notify_configinfo(win, pattern, slot=nil)
609
+ pattern = "<#{pattern}>"
610
+ itemconfiginfo(['notify', [win, pattern]], slot)
611
+ end
612
+ def current_notify_configinfo(tagOrId, slot=nil)
613
+ pattern = "<#{pattern}>"
614
+ current_itemconfiginfo(['notify', [win, pattern]], slot)
615
+ end
616
+
617
+ def style_cget_tkstring(tagOrId, option)
618
+ itemcget_tkstring(['style', tagOrId], option)
619
+ end
620
+ def style_cget(tagOrId, option)
621
+ itemcget(['style', tagOrId], option)
622
+ end
623
+ def style_cget_strict(tagOrId, option)
624
+ itemcget_strict(['style', tagOrId], option)
625
+ end
626
+ def style_configure(tagOrId, slot, value=None)
627
+ itemconfigure(['style', tagOrId], slot, value)
628
+ end
629
+ def style_configinfo(tagOrId, slot=nil)
630
+ itemconfiginfo(['style', tagOrId], slot)
631
+ end
632
+ def current_style_configinfo(tagOrId, slot=nil)
633
+ current_itemconfiginfo(['style', tagOrId], slot)
634
+ end
635
+
636
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
637
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
638
+ end
639
+
640
+ ##############################################
641
+
642
+ class Tk::TreeCtrl
643
+ include Tk::TreeCtrl::ConfigMethod
644
+ include Scrollable
645
+
646
+ TkCommandNames = ['treectrl'.freeze].freeze
647
+ WidgetClassName = 'TreeCtrl'.freeze
648
+ WidgetClassNames[WidgetClassName] ||= self
649
+
650
+ #########################
651
+
652
+ def __destroy_hook__
653
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
654
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
655
+ }
656
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
657
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
658
+ }
659
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
660
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
661
+ }
662
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
663
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
664
+ }
665
+ end
666
+
667
+ #########################
668
+
669
+ def __strval_optkeys
670
+ super() + [
671
+ 'buttoncolor', 'columnprefix', 'itemprefix', 'linecolor'
672
+ ]
673
+ end
674
+ private :__strval_optkeys
675
+
676
+ def __boolval_optkeys
677
+ [
678
+ 'itemwidthequal', 'usetheme',
679
+ 'showbuttons', 'showheader', 'showlines', 'showroot',
680
+ 'showrootbutton', 'showrootlines', 'showrootchildbuttons'
681
+ ]
682
+ end
683
+ private :__boolval_optkeys
684
+
685
+ def __listval_optkeys
686
+ [ 'defaultstyle' ]
687
+ end
688
+ private :__listval_optkeys
689
+
690
+ #########################
691
+
692
+ def install_bind(cmd, *args)
693
+ install_bind_for_event_class(Tk::TreeCtrl::NotifyEvent, cmd, *args)
694
+ end
695
+
696
+ #########################
697
+
698
+ def create_self(keys)
699
+ if keys and keys != None
700
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
701
+ *hash_kv(keys, true))
702
+ else
703
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
704
+ end
705
+ end
706
+ private :create_self
707
+
708
+ #########################
709
+
710
+ def activate(desc)
711
+ tk_send('activate', desc)
712
+ self
713
+ end
714
+
715
+ def canvasx(x)
716
+ number(tk_send('canvasx', x))
717
+ end
718
+
719
+ def canvasy(y)
720
+ number(tk_send('canvasy', y))
721
+ end
722
+
723
+ def collapse(*dsc)
724
+ tk_send_without_enc('collapse', *(dsc.map!{|d| _get_eval_string(d, true)}))
725
+ self
726
+ end
727
+
728
+ def collapse_recurse(*dsc)
729
+ tk_send_without_enc('collapse', '-recurse',
730
+ *(dsc.map!{|d| _get_eval_string(d, true)}))
731
+ self
732
+ end
733
+
734
+ def column_bbox(idx)
735
+ list(tk_send('column', 'bbox', idx))
736
+ end
737
+
738
+ def column_compare(column1, op, column2)
739
+ bool(tk_send('column', 'compare', column1, op, column2))
740
+ end
741
+
742
+ def column_count
743
+ num_or_str(tk_send('column', 'count'))
744
+ end
745
+
746
+ def column_create(keys=nil)
747
+ if keys && keys.kind_of?(Hash)
748
+ num_or_str(tk_send('column', 'create', *hash_kv(keys)))
749
+ else
750
+ num_or_str(tk_send('column', 'create'))
751
+ end
752
+ end
753
+
754
+ def column_delete(idx)
755
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
756
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
757
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
758
+ end
759
+ }
760
+ tk_send('column', 'delete', idx)
761
+ self
762
+ end
763
+
764
+ def column_index(idx)
765
+ num_or_str(tk_send('column', 'index', idx))
766
+ end
767
+
768
+ def column_id(idx)
769
+ tk_send('column', 'id', idx)
770
+ end
771
+
772
+ def column_list(visible=false)
773
+ if visible
774
+ simplelist(tk_send('column', 'list', '-visible'))
775
+ else
776
+ simplelist(tk_send('column', 'list'))
777
+ end
778
+ end
779
+ def column_visible_list
780
+ column_list(true)
781
+ end
782
+
783
+ def column_move(idx, before)
784
+ tk_send('column', 'move', idx, before)
785
+ self
786
+ end
787
+
788
+ def column_needed_width(idx)
789
+ num_or_str(tk_send('column', 'neededwidth', idx))
790
+ end
791
+ alias column_neededwidth column_needed_width
792
+
793
+ def column_order(column, visible=false)
794
+ if visible
795
+ num_or_str(tk_send('column', 'order', column, '-visible'))
796
+ else
797
+ num_or_str(tk_send('column', 'order', column))
798
+ end
799
+ end
800
+ def column_visible_order(column)
801
+ column_order(column, true)
802
+ end
803
+
804
+ def column_width(idx)
805
+ num_or_str(tk_send('column', 'width', idx))
806
+ end
807
+
808
+ def compare(item1, op, item2)
809
+ bool(tk_send('compare', item1, op, item2))
810
+ end
811
+
812
+ def contentbox()
813
+ list(tk_send('contentbox'))
814
+ end
815
+
816
+ def depth(item=None)
817
+ num_or_str(tk_send_without_enc('depth', _get_eval_string(item, true)))
818
+ end
819
+
820
+ def dragimage_add(item, *args)
821
+ tk_send('dragimage', 'add', item, *args)
822
+ self
823
+ end
824
+
825
+ def dragimage_clear()
826
+ tk_send('dragimage', 'clear')
827
+ self
828
+ end
829
+
830
+ def dragimage_offset(*args) # x, y
831
+ if args.empty?
832
+ list(tk_send('dragimage', 'offset'))
833
+ else
834
+ tk_send('dragimage', 'offset', *args)
835
+ self
836
+ end
837
+ end
838
+
839
+ def dragimage_visible(*args) # mode
840
+ if args..empty?
841
+ bool(tk_send('dragimage', 'visible'))
842
+ else
843
+ tk_send('dragimage', 'visible', *args)
844
+ self
845
+ end
846
+ end
847
+ def dragimage_visible?
848
+ dragimage_visible()
849
+ end
850
+
851
+ def debug_dinfo
852
+ tk_send('debug', 'dinfo')
853
+ self
854
+ end
855
+
856
+ def debug_scroll
857
+ tk_send('debug', 'scroll')
858
+ end
859
+
860
+ def element_create(elem, type, keys=nil)
861
+ if keys && keys.kind_of?(Hash)
862
+ tk_send('element', 'create', elem, type, *hash_kv(keys))
863
+ else
864
+ tk_send('element', 'create', elem, type)
865
+ end
866
+ end
867
+
868
+ def element_delete(*elems)
869
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
870
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
871
+ elems.each{|elem|
872
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
873
+ }
874
+ end
875
+ }
876
+ tk_send('element', 'delete', *elems)
877
+ self
878
+ end
879
+
880
+ def element_names()
881
+ list(tk_send('element', 'names')).collect!{|elem|
882
+ Tk::TreeCtrl::Element.id2obj(self, elem)
883
+ }
884
+ end
885
+
886
+ def _conv_element_perstate_val(opt, val)
887
+ case opt
888
+ when 'background', 'foreground', 'fill', 'outline', 'format'
889
+ val
890
+ when 'draw', 'filled', 'showfocus', 'destroy'
891
+ bool(val)
892
+ else
893
+ tk_tcl2ruby(val)
894
+ end
895
+ end
896
+ private :_conv_element_perstate_val
897
+
898
+ def element_perstate(elem, opt, st_list)
899
+ tk_send('element', 'perstate', elem, "-{opt}", st_list)
900
+ end
901
+
902
+ def element_type(elem)
903
+ tk_send('element', 'type', elem)
904
+ end
905
+
906
+ def element_class(elem)
907
+ Tk::TreeCtrl::Element.type2class(element_type(elem))
908
+ end
909
+
910
+ def expand(*dsc)
911
+ tk_send('expand', *dsc)
912
+ self
913
+ end
914
+
915
+ def expand_recurse(*dsc)
916
+ tk_send('expand', '-recurse', *dsc)
917
+ self
918
+ end
919
+
920
+ def identify(x, y)
921
+ lst = list(tk_send('identify', x, y))
922
+
923
+ if lst[0] == 'item'
924
+ lst[1] = Tk::TreeCtrl::Item.id2obj(self, lst[1])
925
+ size = lst.size
926
+ i = 2
927
+ while i < size
928
+ case lst[i]
929
+ when 'line'
930
+ i += 1
931
+ lst[i] = Tk::TreeCtrl::Item.id2obj(self, lst[i])
932
+ i += 1
933
+
934
+ when 'button'
935
+ i += 1
936
+
937
+ when 'column'
938
+ i += 2
939
+
940
+ when 'elem'
941
+ i += 1
942
+ lst[i] = Tk::TreeCtrl::Element.id2obj(self, lst[i])
943
+ i += 1
944
+
945
+ else
946
+ i += 1
947
+ end
948
+ end
949
+ end
950
+
951
+ lst
952
+ end
953
+
954
+ def index(idx)
955
+ num_or_str(tk_send('index', idx))
956
+ end
957
+
958
+ def item_ancestors(item)
959
+ list(tk_send('item', 'ancestors', item)).collect!{|id|
960
+ Tk::TreeCtrl::Item.id2obj(self, id)
961
+ }
962
+ end
963
+
964
+ def item_bbox(item, *args)
965
+ list(tk_send('item', 'bbox', item, *args))
966
+ end
967
+
968
+ def item_children(item)
969
+ list(tk_send('item', 'children', item)).collect!{|id|
970
+ Tk::TreeCtrl::Item.id2obj(self, id)
971
+ }
972
+ end
973
+
974
+ def item_collapse(item)
975
+ tk_send_without_enc('item', 'collapse', _get_eval_string(item, true))
976
+ self
977
+ end
978
+
979
+ def item_collapse_recurse(item)
980
+ tk_send_without_enc('item', 'collapse',
981
+ _get_eval_string(item, true), '-recurse')
982
+ self
983
+ end
984
+
985
+ def item_compare(item1, op, item2)
986
+ bool(tk_send('item', 'compare', item1, op, item2))
987
+ end
988
+
989
+ def item_complex(item, *args)
990
+ tk_send_without_enc('item', 'complex',
991
+ _get_eval_string(item, true),
992
+ *(args.map!{|arg| _get_eval_string(arg, true)}))
993
+ self
994
+ end
995
+
996
+ def item_count
997
+ num_or_str(tk_send('item', 'count'))
998
+ end
999
+
1000
+ def item_create(keys={})
1001
+ num_or_str(tk_send_without_enc('item', 'create', *hash_kv(keys, true)))
1002
+ end
1003
+
1004
+ def _erase_children(item)
1005
+ item_children(item).each{|i| _erase_children(i)}
1006
+ # table is already locked
1007
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].delete(item)
1008
+ end
1009
+ private :_erase_children
1010
+
1011
+ def item_delete(first, last=None)
1012
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
1013
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
1014
+ if first == 'all' || first == :all || last == 'all' || last == :all
1015
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
1016
+ elsif last == None
1017
+ _erase_children(first)
1018
+ else
1019
+ self.range(first, last).each{|id|
1020
+ _erase_children(id)
1021
+ }
1022
+ end
1023
+ end
1024
+ }
1025
+ tk_send('item', 'delete', first, last)
1026
+ self
1027
+ end
1028
+
1029
+ def item_dump(item)
1030
+ list(tk_send('item', 'dump', item))
1031
+ end
1032
+
1033
+ def item_dump_hash(item)
1034
+ Hash[*list(tk_send('item', 'dump', item))]
1035
+ end
1036
+
1037
+ def item_element_actual(item, column, elem, key)
1038
+ tk_send('item', 'element', 'actual', item, column, elem, "-#{key}")
1039
+ end
1040
+
1041
+ def item_element_perstate(elem, opt, st_list)
1042
+ tk_send('item', 'element', 'perstate', elem, "-{opt}", st_list)
1043
+ end
1044
+
1045
+ def item_expand(item)
1046
+ tk_send('item', 'expand', item)
1047
+ self
1048
+ end
1049
+
1050
+ def item_expand_recurse(item)
1051
+ tk_send('item', 'expand', item, '-recurse')
1052
+ self
1053
+ end
1054
+
1055
+ def item_firstchild(parent, child=nil)
1056
+ if child
1057
+ tk_send_without_enc('item', 'firstchild',
1058
+ _get_eval_string(parent, true),
1059
+ _get_eval_string(child, true))
1060
+ self
1061
+ else
1062
+ id = num_or_str(tk_send_without_enc('item', 'firstchild',
1063
+ _get_eval_string(parent, true)))
1064
+ Tk::TreeCtrl::Item.id2obj(self, id)
1065
+ end
1066
+ end
1067
+ alias item_first_child item_firstchild
1068
+
1069
+ def item_hasbutton(item, st=None)
1070
+ if st == None
1071
+ bool(tk_send_without_enc('item', 'hasbutton',
1072
+ _get_eval_string(item, true)))
1073
+ else
1074
+ tk_send_without_enc('item', 'hasbutton',
1075
+ _get_eval_string(item, true),
1076
+ _get_eval_string(st))
1077
+ self
1078
+ end
1079
+ end
1080
+ alias item_has_button item_hasbutton
1081
+
1082
+ def item_hasbutton?(item)
1083
+ item_hasbutton(item)
1084
+ end
1085
+ alias item_has_button? item_hasbutton?
1086
+
1087
+ def item_id(item)
1088
+ tk_send('item', 'id', item)
1089
+ end
1090
+
1091
+ def item_image(item, column=nil, *args)
1092
+ if args.empty?
1093
+ if column
1094
+ img = tk_send('item', 'image', item, column)
1095
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
1096
+ else
1097
+ simplelist(tk_send('item', 'image', item)).collect!{|img|
1098
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
1099
+ }
1100
+ end
1101
+ else
1102
+ tk_send('item', 'image', item, column, *args)
1103
+ self
1104
+ end
1105
+ end
1106
+ def get_item_image(item, column=nil)
1107
+ item_image(item, column)
1108
+ end
1109
+ def set_item_image(item, col, img, *args)
1110
+ item_image(item, col, img, *args)
1111
+ end
1112
+
1113
+ def item_index(item)
1114
+ list(tk_send('item', 'index', item))
1115
+ end
1116
+
1117
+ def item_isancestor(item, des)
1118
+ bool(tk_send('item', 'isancestor', item, des))
1119
+ end
1120
+ alias item_is_ancestor item_isancestor
1121
+ alias item_isancestor? item_isancestor
1122
+ alias item_is_ancestor? item_isancestor
1123
+
1124
+ def item_isopen(item)
1125
+ bool(tk_send('item', 'isopen', item))
1126
+ end
1127
+ alias item_is_open item_isopen
1128
+ alias item_isopen? item_isopen
1129
+ alias item_is_open? item_isopen
1130
+ alias item_isopened? item_isopen
1131
+ alias item_is_opened? item_isopen
1132
+
1133
+ def item_lastchild(parent, child=nil)
1134
+ if child
1135
+ tk_send_without_enc('item', 'lastchild',
1136
+ _get_eval_string(parent, true),
1137
+ _get_eval_string(child, true))
1138
+ self
1139
+ else
1140
+ id = num_or_str(tk_send_without_enc('item', 'lastchild',
1141
+ _get_eval_string(parent, true)))
1142
+ Tk::TreeCtrl::Item.id2obj(self, id)
1143
+ end
1144
+ end
1145
+ alias item_last_child item_lastchild
1146
+
1147
+ def item_nextsibling(sibling, nxt=nil)
1148
+ if nxt
1149
+ tk_send('item', 'nextsibling', sibling, nxt)
1150
+ self
1151
+ else
1152
+ id = num_or_str(tk_send('item', 'nextsibling', sibling))
1153
+ Tk::TreeCtrl::Item.id2obj(self, id)
1154
+ end
1155
+ end
1156
+ alias item_next_sibling item_nextsibling
1157
+
1158
+ def item_numchildren(item)
1159
+ number(tk_send_without_enc('item', 'numchildren',
1160
+ _get_eval_string(item, true)))
1161
+ end
1162
+ alias item_num_children item_numchildren
1163
+ alias item_children_size item_numchildren
1164
+
1165
+ def item_order(item, visible=false)
1166
+ if visible
1167
+ ret = num_or_str(tk_send('item', 'order', item, '-visible'))
1168
+ else
1169
+ ret = num_or_str(tk_send('item', 'order', item))
1170
+ end
1171
+
1172
+ (ret.kind_of?(Fixnum) && ret < 0)? nil: ret
1173
+ end
1174
+ def item_visible_order(item)
1175
+ item_order(item, true)
1176
+ end
1177
+
1178
+ def item_parent(item)
1179
+ id = num_or_str(tk_send('item', 'parent', item))
1180
+ Tk::TreeCtrl::Item.id2obj(self, id)
1181
+ end
1182
+
1183
+ def item_prevsibling(sibling, prev=nil)
1184
+ if prev
1185
+ tk_send('item', 'prevsibling', sibling, prev)
1186
+ self
1187
+ else
1188
+ id = num_or_str(tk_send('item', 'prevsibling', sibling))
1189
+ Tk::TreeCtrl::Item.id2obj(self, id)
1190
+ end
1191
+ end
1192
+ alias item_prev_sibling item_prevsibling
1193
+
1194
+ def item_range(first, last)
1195
+ simplelist(tk_send('item', 'range', first, last))
1196
+ end
1197
+
1198
+ def item_remove(item)
1199
+ tk_send('item', 'remove', item)
1200
+ self
1201
+ end
1202
+
1203
+ def item_rnc(item)
1204
+ list(tk_send('item', 'rnc', item))
1205
+ end
1206
+
1207
+ def _item_sort_core(real_sort, item, *opts)
1208
+ # opts ::= sort_param [, sort_param, ... ]
1209
+ # sort_param ::= {key=>val, ...}
1210
+ # [type, desc, {key=>val, ...}]
1211
+ # param
1212
+ opts = opts.collect{|param|
1213
+ if param.kind_of?(Hash)
1214
+ param = _symbolkey2str(param)
1215
+ if param.key?('column')
1216
+ key = '-column'
1217
+ desc = param.delete('column')
1218
+ elsif param.key?('element')
1219
+ key = '-element'
1220
+ desc = param.delete('element')
1221
+ else
1222
+ key = nil
1223
+ end
1224
+
1225
+ if param.empty?
1226
+ param = None
1227
+ else
1228
+ param = hash_kv(__conv_item_keyonly_opts(item, param))
1229
+ end
1230
+
1231
+ if key
1232
+ [key, desc].concat(param)
1233
+ else
1234
+ param
1235
+ end
1236
+
1237
+ elsif param.kind_of?(Array)
1238
+ if param[2].kind_of?(Hash)
1239
+ param[2] = hash_kv(__conv_item_keyonly_opts(item, param[2]))
1240
+ end
1241
+ param
1242
+
1243
+ elsif param.kind_of?(String) && param =~ /\A[a-z]+\Z/
1244
+ '-' << param
1245
+
1246
+ elsif param.kind_of?(Symbol)
1247
+ '-' << param.to_s
1248
+
1249
+ else
1250
+ param
1251
+ end
1252
+ }.flatten
1253
+
1254
+ if real_sort
1255
+ tk_send('item', 'sort', item, *opts)
1256
+ self
1257
+ else
1258
+ list(tk_send('item', 'sort', item, '-notreally', *opts))
1259
+ end
1260
+ end
1261
+ private :_item_sort_core
1262
+
1263
+ def item_sort(item, *opts)
1264
+ _item_sort_core(true, item, *opts)
1265
+ end
1266
+ def item_sort_not_really(item, *opts)
1267
+ _item_sort_core(false, item, *opts)
1268
+ end
1269
+
1270
+ def item_span(item, column=nil, *args)
1271
+ if args.empty?
1272
+ if column
1273
+ list(tk_send('item', 'span', item, column))
1274
+ else
1275
+ simplelist(tk_send('item', 'span', item)).collect!{|elem| list(elem)}
1276
+ end
1277
+ else
1278
+ tk_send('item', 'span', item, column, *args)
1279
+ self
1280
+ end
1281
+ end
1282
+ def get_item_span(item, column=nil)
1283
+ item_span(item, column)
1284
+ end
1285
+ def set_item_span(item, col, num, *args)
1286
+ item_span(item, col, num, *args)
1287
+ end
1288
+
1289
+ def item_state_forcolumn(item, column, *args)
1290
+ tk_send('item', 'state', 'forcolumn', item, column, *args)
1291
+ end
1292
+ alias item_state_for_column item_state_forcolumn
1293
+
1294
+ def item_state_get(item, *args)
1295
+ if args.empty?
1296
+ list(tk_send('item', 'state', 'get', item *args))
1297
+ else
1298
+ bool(tk_send('item', 'state', 'get', item))
1299
+ end
1300
+ end
1301
+
1302
+ def item_state_set(item, *args)
1303
+ tk_send('item', 'state', 'set', item, *args)
1304
+ end
1305
+
1306
+ def item_style_elements(item, column)
1307
+ list(tk_send('item', 'style', 'elements', item, column)).collect!{|id|
1308
+ Tk::TreeCtrl::Style.id2obj(self, id)
1309
+ }
1310
+ end
1311
+
1312
+ def item_style_map(item, column, style, map)
1313
+ tk_send('item', 'style', 'map', item, column, style, map)
1314
+ self
1315
+ end
1316
+
1317
+ def item_style_set(item, column=nil, *args)
1318
+ if args.empty?
1319
+ if column
1320
+ id = tk_send_without_enc('item', 'style', 'set',
1321
+ _get_eval_string(item, true),
1322
+ _get_eval_string(column, true))
1323
+ Tk::TreeCtrl::Style.id2obj(self, id)
1324
+ else
1325
+ list(tk_send_without_enc('item', 'style', 'set',
1326
+ _get_eval_string(item, true))).collect!{|id|
1327
+ Tk::TreeCtrl::Style.id2obj(self, id)
1328
+ }
1329
+ end
1330
+ else
1331
+ tk_send_without_enc('item', 'style', 'set',
1332
+ _get_eval_string(item, true),
1333
+ _get_eval_string(column, true),
1334
+ *(args.flatten.map!{|arg|
1335
+ _get_eval_string(arg, true)
1336
+ }))
1337
+ self
1338
+ end
1339
+ end
1340
+
1341
+ def item_text(item, column, txt=nil, *args)
1342
+ if args.empty?
1343
+ if txt
1344
+ tk_send('item', 'text', item, column, txt)
1345
+ self
1346
+ else
1347
+ tk_send('item', 'text', item, column)
1348
+ end
1349
+ else
1350
+ tk_send('item', 'text', item, column, txt, *args)
1351
+ self
1352
+ end
1353
+ end
1354
+
1355
+ def item_toggle(item)
1356
+ tk_send('item', 'toggle', item)
1357
+ self
1358
+ end
1359
+
1360
+ def item_toggle_recurse(item)
1361
+ tk_send('item', 'toggle', item, '-recurse')
1362
+ self
1363
+ end
1364
+
1365
+ def item_visible(item, st=None)
1366
+ if st == None
1367
+ bool(tk_send('item', 'visible', item))
1368
+ else
1369
+ tk_send('item', 'visible', item, st)
1370
+ self
1371
+ end
1372
+ end
1373
+ def item_visible?(item)
1374
+ item_visible(item)
1375
+ end
1376
+
1377
+ def marquee_anchor(*args)
1378
+ if args.empty?
1379
+ list(tk_send('marquee', 'anchor'))
1380
+ else
1381
+ tk_send('marquee', 'anchor', *args)
1382
+ self
1383
+ end
1384
+ end
1385
+
1386
+ def marquee_coords(*args)
1387
+ if args.empty?
1388
+ list(tk_send('marquee', 'coords'))
1389
+ else
1390
+ tk_send('marquee', 'coords', *args)
1391
+ self
1392
+ end
1393
+ end
1394
+
1395
+ def marquee_corner(*args)
1396
+ if args.empty?
1397
+ tk_send('marquee', 'corner')
1398
+ else
1399
+ tk_send('marquee', 'corner', *args)
1400
+ self
1401
+ end
1402
+ end
1403
+
1404
+ def marquee_identify()
1405
+ list(tk_send('marquee', 'identify')).collect!{|id|
1406
+ Tk::TreeCtrl::Item.id2obj(self, id)
1407
+ }
1408
+ end
1409
+
1410
+ def marquee_visible(st=None)
1411
+ if st == None
1412
+ bool(tk_send('marquee', 'visible'))
1413
+ else
1414
+ tk_send('marquee', 'visible', st)
1415
+ self
1416
+ end
1417
+ end
1418
+ def marquee_visible?()
1419
+ marquee_visible()
1420
+ end
1421
+
1422
+ #def notify_bind(obj, event, cmd=Proc.new, *args)
1423
+ # _bind([@path, 'notify', 'bind', obj], event, cmd, *args)
1424
+ # self
1425
+ #end
1426
+ def notify_bind(obj, event, *args)
1427
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
1428
+ if TkComm._callback_entry?(args[0]) || !block_given?
1429
+ cmd = args.shift
1430
+ else
1431
+ cmd = Proc.new
1432
+ end
1433
+ _bind([@path, 'notify', 'bind', obj], event, cmd, *args)
1434
+ self
1435
+ end
1436
+
1437
+ #def notify_bind_append(obj, event, cmd=Proc.new, *args)
1438
+ # _bind_append([@path, 'notify', 'bind', obj], event, cmd, *args)
1439
+ # self
1440
+ #end
1441
+ def notify_bind_append(obj, event, *args)
1442
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
1443
+ if TkComm._callback_entry?(args[0]) || !block_given?
1444
+ cmd = args.shift
1445
+ else
1446
+ cmd = Proc.new
1447
+ end
1448
+ _bind_append([@path, 'notify', 'bind', obj], event, cmd, *args)
1449
+ self
1450
+ end
1451
+
1452
+ def notify_bind_remove(obj, event)
1453
+ _bind_remove([@path, 'notify', 'bind', obj], event)
1454
+ self
1455
+ end
1456
+
1457
+ def notify_bindinfo(obj, event=nil)
1458
+ _bindinfo([@path, 'notify', 'bind', obj], event)
1459
+ end
1460
+
1461
+ def notify_detailnames(event)
1462
+ list(tk_send('notify', 'detailnames', event))
1463
+ end
1464
+
1465
+ def notify_eventnames()
1466
+ list(tk_send('notify', 'eventnames'))
1467
+ end
1468
+
1469
+ def notify_generate(pattern, char_map=None, percents_cmd=None)
1470
+ pattern = "<#{pattern}>"
1471
+ tk_send('notify', 'generate', pattern, char_map, percents_cmd)
1472
+ self
1473
+ end
1474
+
1475
+ def notify_install(pattern, percents_cmd=nil, &b)
1476
+ pattern = "<#{pattern}>"
1477
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
1478
+ if percents_cmd
1479
+ procedure(tk_send('notify', 'install', pattern, percents_cmd))
1480
+ else
1481
+ procedure(tk_send('notify', 'install', pattern))
1482
+ end
1483
+ end
1484
+
1485
+ def notify_install_detail(event, detail, percents_cmd=nil, &b)
1486
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
1487
+ if percents_cmd
1488
+ tk_send('notify', 'install', 'detail', event, detail, percents_cmd)
1489
+ else
1490
+ tk_send('notify', 'install', 'detail', event, detail)
1491
+ end
1492
+ end
1493
+
1494
+ def notify_install_event(event, percents_cmd=nil, &b)
1495
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
1496
+ if percents_cmd
1497
+ tk_send('notify', 'install', 'event', event, percents_cmd)
1498
+ else
1499
+ tk_send('notify', 'install', 'event', event)
1500
+ end
1501
+ end
1502
+
1503
+ def notify_linkage(pattern, detail=None)
1504
+ if detail != None
1505
+ tk_send('notify', 'linkage', pattern, detail)
1506
+ else
1507
+ begin
1508
+ if pattern.to_s.index(?-)
1509
+ # TreeCtrl 1.1 format?
1510
+ begin
1511
+ tk_send('notify', 'linkage', "<#{pattern}>")
1512
+ rescue
1513
+ # TreeCtrl 1.0?
1514
+ tk_send('notify', 'linkage', pattern)
1515
+ end
1516
+ else
1517
+ # TreeCtrl 1.0 format?
1518
+ begin
1519
+ tk_send('notify', 'linkage', pattern)
1520
+ rescue
1521
+ # TreeCtrl 1.1?
1522
+ tk_send('notify', 'linkage', "<#{pattern}>")
1523
+ end
1524
+ end
1525
+ end
1526
+ end
1527
+ end
1528
+
1529
+ def notify_unbind(pattern=nil)
1530
+ if pattern
1531
+ tk_send('notify', 'unbind', "<#{pattern}>")
1532
+ else
1533
+ tk_send('notify', 'unbind')
1534
+ end
1535
+ self
1536
+ end
1537
+
1538
+ def notify_uninstall(pattern)
1539
+ pattern = "<#{pattern}>"
1540
+ tk_send('notify', 'uninstall', pattern)
1541
+ self
1542
+ end
1543
+
1544
+ def notify_uninstall_detail(event, detail)
1545
+ tk_send('notify', 'uninstall', 'detail', event, detail)
1546
+ self
1547
+ end
1548
+
1549
+ def notify_uninstall_event(event)
1550
+ tk_send('notify', 'uninstall', 'event', event)
1551
+ self
1552
+ end
1553
+
1554
+ def numcolumns()
1555
+ num_or_str(tk_send('numcolumns'))
1556
+ end
1557
+ alias num_columns numcolumns
1558
+ alias columns_size numcolumns
1559
+
1560
+ def numitems()
1561
+ num_or_str(tk_send('numitems'))
1562
+ end
1563
+ alias num_items numitems
1564
+ alias items_size numitems
1565
+
1566
+ def orphans()
1567
+ list(tk_send('orphans')).collect!{|id|
1568
+ Tk::TreeCtrl::Item.id2obj(self, id)
1569
+ }
1570
+ end
1571
+
1572
+ def range(first, last)
1573
+ list(tk_send('range', first, last)).collect!{|id|
1574
+ Tk::TreeCtrl::Item.id2obj(self, id)
1575
+ }
1576
+ end
1577
+
1578
+ def state_define(name)
1579
+ tk_send('state', 'define', name)
1580
+ self
1581
+ end
1582
+
1583
+ def state_linkage(name)
1584
+ tk_send('state', 'linkage', name)
1585
+ end
1586
+
1587
+ def state_names()
1588
+ list(tk_send('state', 'names'))
1589
+ end
1590
+
1591
+ def state_undefine(*names)
1592
+ tk_send('state', 'undefine', *names)
1593
+ self
1594
+ end
1595
+
1596
+ def see(item, column=None, keys={})
1597
+ tk_send('see', item, column, *hash_kv(keys))
1598
+ self
1599
+ end
1600
+
1601
+ def selection_add(first, last=None)
1602
+ tk_send('selection', 'add', first, last)
1603
+ self
1604
+ end
1605
+
1606
+ def selection_anchor(item=None)
1607
+ id = num_or_str(tk_send('selection', 'anchor', item))
1608
+ Tk::TreeCtrl::Item.id2obj(self, id)
1609
+ end
1610
+
1611
+ def selection_clear(*args) # first, last
1612
+ tk_send('selection', 'clear', *args)
1613
+ self
1614
+ end
1615
+
1616
+ def selection_count()
1617
+ number(tk_send('selection', 'count'))
1618
+ end
1619
+
1620
+ def selection_get()
1621
+ list(tk_send('selection', 'get')).collect!{|id|
1622
+ Tk::TreeCtrl::Item.id2obj(self, id)
1623
+ }
1624
+ end
1625
+
1626
+ def selection_includes(item)
1627
+ bool(tk_send('selection', 'includes', item))
1628
+ end
1629
+
1630
+ def selection_modify(sel, desel)
1631
+ tk_send('selection', 'modify', sel, desel)
1632
+ self
1633
+ end
1634
+
1635
+ def style_create(style, keys=None)
1636
+ if keys && keys != None
1637
+ tk_send('style', 'create', style, *hash_kv(keys))
1638
+ else
1639
+ tk_send('style', 'create', style)
1640
+ end
1641
+ end
1642
+
1643
+ def style_delete(*args)
1644
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
1645
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
1646
+ args.each{|sty|
1647
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
1648
+ }
1649
+ end
1650
+ }
1651
+ tk_send('style', 'delete', *args)
1652
+ self
1653
+ end
1654
+
1655
+ def style_elements(style, *elems)
1656
+ if elems.empty?
1657
+ list(tk_send('style', 'elements', style)).collect!{|id|
1658
+ Tk::TreeCtrl::Element.id2obj(self, id)
1659
+ }
1660
+ else
1661
+ tk_send('style', 'elements', style, elems.flatten)
1662
+ self
1663
+ end
1664
+ end
1665
+
1666
+ def _conv_style_layout_val(sty, val)
1667
+ case sty.to_s
1668
+ when 'padx', 'pady', 'ipadx', 'ipady'
1669
+ lst = list(val)
1670
+ (lst.size == 1)? lst[0]: lst
1671
+ when 'detach', 'indent'
1672
+ bool(val)
1673
+ when 'union'
1674
+ simplelist(val).collect!{|elem|
1675
+ Tk::TreeCtrl::Element.id2obj(self, elem)
1676
+ }
1677
+ else
1678
+ val
1679
+ end
1680
+ end
1681
+ private :_conv_style_layout_val
1682
+
1683
+ def style_layout(style, elem, keys=None)
1684
+ if keys && keys != None
1685
+ if keys.kind_of?(Hash)
1686
+ tk_send('style', 'layout', style, elem, *hash_kv(keys))
1687
+ self
1688
+ else
1689
+ _conv_style_layout_val(keys,
1690
+ tk_send('style', 'layout',
1691
+ style, elem, "-#{keys}"))
1692
+ end
1693
+ else
1694
+ ret = Hash.new
1695
+ Hash[*simplelist(tk_send('style', 'layout', style, elem))].each{|k, v|
1696
+ k = k[1..-1]
1697
+ ret[k] = _conv_style_layout_val(k, v)
1698
+ }
1699
+ ret
1700
+ end
1701
+ end
1702
+ def get_style_layout(style, elem, opt=None)
1703
+ style_layout(style, elem, opt)
1704
+ end
1705
+ def set_style_layout(style, elem, slot, value=None)
1706
+ if slot.kind_of?(Hash)
1707
+ style_layout(style, elem, slot)
1708
+ else
1709
+ style_layout(style, elem, {slot=>value})
1710
+ end
1711
+ end
1712
+
1713
+ def style_names()
1714
+ list(tk_send('style', 'names')).collect!{|id|
1715
+ Tk::TreeCtrl::Style.id2obj(self, id)
1716
+ }
1717
+ end
1718
+
1719
+ def toggle(*items)
1720
+ tk_send('toggle', *items)
1721
+ self
1722
+ end
1723
+
1724
+ def toggle_recurse()
1725
+ tk_send('toggle', '-recurse', *items)
1726
+ self
1727
+ end
1728
+ end
1729
+
1730
+ #####################
1731
+
1732
+ class Tk::TreeCtrl::Column < TkObject
1733
+ TreeCtrlColumnID_TBL = TkCore::INTERP.create_table
1734
+
1735
+ (TreeCtrlColumnID = ['treectrl_column'.freeze, TkUtil.untrust('00000')]).instance_eval{
1736
+ @mutex = Mutex.new
1737
+ def mutex; @mutex; end
1738
+ freeze
1739
+ }
1740
+
1741
+ TkCore::INTERP.init_ip_env{
1742
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
1743
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear
1744
+ }
1745
+ }
1746
+
1747
+ def self.id2obj(tree, id)
1748
+ tpath = tree.path
1749
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
1750
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
1751
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
1752
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
1753
+ else
1754
+ id
1755
+ end
1756
+ }
1757
+ end
1758
+
1759
+ def initialize(parent, keys={})
1760
+ @tree = parent
1761
+ @tpath = parent.path
1762
+
1763
+ keys = _symbolkey2str(keys)
1764
+
1765
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.mutex.synchronize{
1766
+ @path = @id =
1767
+ keys.delete('tag') ||
1768
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
1769
+ Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
1770
+ }
1771
+
1772
+ keys['tag'] = @id
1773
+
1774
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
1775
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] ||= {}
1776
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
1777
+ }
1778
+
1779
+ @tree.column_create(keys)
1780
+ end
1781
+
1782
+ def id
1783
+ @id
1784
+ end
1785
+
1786
+ def to_s
1787
+ @id.to_s.dup
1788
+ end
1789
+
1790
+ def cget_tkstring(opt)
1791
+ @tree.column_cget_tkstring(@tree.column_index(@id), opt)
1792
+ end
1793
+ def cget(opt)
1794
+ @tree.column_cget(@tree.column_index(@id), opt)
1795
+ end
1796
+ def cget_strict(opt)
1797
+ @tree.column_cget_strict(@tree.column_index(@id), opt)
1798
+ end
1799
+
1800
+ def configure(*args)
1801
+ @tree.column_configure(@tree.column_index(@id), *args)
1802
+ end
1803
+
1804
+ def configinfo(*args)
1805
+ @tree.column_configinfo(@tree.column_index(@id), *args)
1806
+ end
1807
+
1808
+ def current_configinfo(*args)
1809
+ @tree.current_column_configinfo(@tree.column_index(@id), *args)
1810
+ end
1811
+
1812
+ def delete
1813
+ @tree.column_delete(@tree.column_index(@id))
1814
+ self
1815
+ end
1816
+
1817
+ def index
1818
+ @tree.column_index(@id)
1819
+ end
1820
+
1821
+ def move(before)
1822
+ @tree.column_move(@tree.column_index(@id), before)
1823
+ self
1824
+ end
1825
+
1826
+ def needed_width
1827
+ @tree.column_needed_width(@tree.column_index(@id))
1828
+ end
1829
+ alias neededwidth needed_width
1830
+
1831
+ def current_width
1832
+ @tree.column_width(@tree.column_index(@id))
1833
+ end
1834
+ end
1835
+
1836
+ #####################
1837
+
1838
+ class Tk::TreeCtrl::Element < TkObject
1839
+ TreeCtrlElementID_TBL = TkCore::INTERP.create_table
1840
+
1841
+ (TreeCtrlElementID = ['treectrl_element'.freeze, TkUtil.untrust('00000')]).instance_eval{
1842
+ @mutex = Mutex.new
1843
+ def mutex; @mutex; end
1844
+ freeze
1845
+ }
1846
+ TreeCtrlElemTypeToClass = {}
1847
+
1848
+ TkCore::INTERP.init_ip_env{
1849
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
1850
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
1851
+ }
1852
+ }
1853
+
1854
+ def self.type2class(type)
1855
+ TreeCtrlElemTypeToClass[type] || type
1856
+ end
1857
+
1858
+ def self.id2obj(tree, id)
1859
+ tpath = tree.path
1860
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
1861
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
1862
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
1863
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id] : id
1864
+ else
1865
+ id
1866
+ end
1867
+ }
1868
+ end
1869
+
1870
+ def initialize(parent, type, keys=nil)
1871
+ @tree = parent
1872
+ @tpath = parent.path
1873
+ @type = type.to_s
1874
+ Tk::TreeCtrl::Element::TreeCtrlElementID.mutex.synchronize{
1875
+ @path = @id =
1876
+ Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
1877
+ Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
1878
+ }
1879
+
1880
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
1881
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] ||= {}
1882
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
1883
+ }
1884
+
1885
+ @tree.element_create(@id, @type, keys)
1886
+ end
1887
+
1888
+ def id
1889
+ @id
1890
+ end
1891
+
1892
+ def to_s
1893
+ @id.dup
1894
+ end
1895
+
1896
+ def cget_tkstring(opt)
1897
+ @tree.element_cget_tkstring(@id, opt)
1898
+ end
1899
+ def cget(opt)
1900
+ @tree.element_cget(@id, opt)
1901
+ end
1902
+ def cget_strict(opt)
1903
+ @tree.element_cget_strict(@id, opt)
1904
+ end
1905
+
1906
+ def configure(*args)
1907
+ @tree.element_configure(@id, *args)
1908
+ end
1909
+
1910
+ def configinfo(*args)
1911
+ @tree.element_configinfo(@id, *args)
1912
+ end
1913
+
1914
+ def current_configinfo(*args)
1915
+ @tree.current_element_configinfo(@id, *args)
1916
+ end
1917
+
1918
+ def delete
1919
+ @tree.element_delete(@id)
1920
+ self
1921
+ end
1922
+
1923
+ def element_type
1924
+ @tree.element_type(@id)
1925
+ end
1926
+
1927
+ def element_class
1928
+ @tree.element_class(@id)
1929
+ end
1930
+ end
1931
+
1932
+ class Tk::TreeCtrl::BitmapElement < Tk::TreeCtrl::Element
1933
+ TreeCtrlElemTypeToClass['bitmap'] = self
1934
+
1935
+ def initialize(parent, keys=nil)
1936
+ super(parent, 'bitmap', keys)
1937
+ end
1938
+ end
1939
+
1940
+ class Tk::TreeCtrl::BorderElement < Tk::TreeCtrl::Element
1941
+ TreeCtrlElemTypeToClass['border'] = self
1942
+
1943
+ def initialize(parent, keys=nil)
1944
+ super(parent, 'border', keys)
1945
+ end
1946
+ end
1947
+
1948
+ class Tk::TreeCtrl::ImageElement < Tk::TreeCtrl::Element
1949
+ TreeCtrlElemTypeToClass['image'] = self
1950
+
1951
+ def initialize(parent, keys=nil)
1952
+ super(parent, 'image', keys)
1953
+ end
1954
+ end
1955
+
1956
+ class Tk::TreeCtrl::RectangleElement < Tk::TreeCtrl::Element
1957
+ TreeCtrlElemTypeToClass['rect'] = self
1958
+
1959
+ def initialize(parent, keys=nil)
1960
+ super(parent, 'rect', keys)
1961
+ end
1962
+ end
1963
+
1964
+ #####################
1965
+
1966
+ class Tk::TreeCtrl::Item < TkObject
1967
+ TreeCtrlItemID_TBL = TkCore::INTERP.create_table
1968
+
1969
+ TkCore::INTERP.init_ip_env{
1970
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
1971
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear
1972
+ }
1973
+ }
1974
+
1975
+ def self.id2obj(tree, id)
1976
+ tpath = tree.path
1977
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
1978
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
1979
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
1980
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
1981
+ else
1982
+ id
1983
+ end
1984
+ }
1985
+ end
1986
+
1987
+ def initialize(parent, keys={})
1988
+ @tree = parent
1989
+ @tpath = parent.path
1990
+ @path = @id = @tree.item_create(keys)
1991
+
1992
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
1993
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] ||= {}
1994
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
1995
+ }
1996
+ end
1997
+
1998
+ def id
1999
+ @id
2000
+ end
2001
+
2002
+ def to_s
2003
+ @id.to_s.dup
2004
+ end
2005
+
2006
+ def ancestors
2007
+ @tree.item_ancestors(@id)
2008
+ end
2009
+
2010
+ def bbox(*args)
2011
+ @tree.item_bbox(@id, *args)
2012
+ end
2013
+
2014
+ def children
2015
+ @tree.item_children(@id)
2016
+ end
2017
+
2018
+ def collapse
2019
+ @tree.item_collapse(@id)
2020
+ self
2021
+ end
2022
+
2023
+ def collapse_recurse
2024
+ @tree.item_collapse_recurse(@id)
2025
+ self
2026
+ end
2027
+
2028
+ def complex(*args)
2029
+ @tree.item_complex(@id, *args)
2030
+ self
2031
+ end
2032
+
2033
+ def cget_tkstring(opt)
2034
+ @tree.item_cget_tkstring(@id, opt)
2035
+ end
2036
+ def cget(opt)
2037
+ @tree.item_cget(@id, opt)
2038
+ end
2039
+ def cget_strict(opt)
2040
+ @tree.item_cget_strict(@id, opt)
2041
+ end
2042
+
2043
+ def configure(*args)
2044
+ @tree.item_configure(@id, *args)
2045
+ end
2046
+
2047
+ def configinfo(*args)
2048
+ @tree.item_configinfo(@id, *args)
2049
+ end
2050
+
2051
+ def current_configinfo(*args)
2052
+ @tree.current_item_configinfo(@id, *args)
2053
+ end
2054
+
2055
+ def delete
2056
+ @tree.item_delete(@id)
2057
+ self
2058
+ end
2059
+
2060
+ def element_dump
2061
+ @tree.item_dump(@id)
2062
+ end
2063
+
2064
+ def element_dump_hash
2065
+ @tree.item_dump_hash(@id)
2066
+ end
2067
+
2068
+ def element_actual(column, elem, key)
2069
+ @tree.item_element_actual(@id, column, elem, key)
2070
+ end
2071
+
2072
+ def element_cget_tkstring(opt)
2073
+ @tree.item_element_cget(@id, opt)
2074
+ end
2075
+ def element_cget_tkstring(opt)
2076
+ @tree.item_element_cget(@id, opt)
2077
+ end
2078
+ def element_cget_strict(opt)
2079
+ @tree.item_element_cget_strict(@id, opt)
2080
+ end
2081
+
2082
+ def element_configure(*args)
2083
+ @tree.item_element_configure(@id, *args)
2084
+ end
2085
+
2086
+ def element_configinfo(*args)
2087
+ @tree.item_element_configinfo(@id, *args)
2088
+ end
2089
+
2090
+ def current_element_configinfo(*args)
2091
+ @tree.current_item_element_configinfo(@id, *args)
2092
+ end
2093
+
2094
+ def expand
2095
+ @tree.item_expand(@id)
2096
+ self
2097
+ end
2098
+
2099
+ def expand_recurse
2100
+ @tree.item_expand_recurse(@id)
2101
+ self
2102
+ end
2103
+
2104
+ def firstchild(child=nil)
2105
+ if child
2106
+ @tree.item_firstchild(@id, child)
2107
+ self
2108
+ else
2109
+ @tree.item_firstchild(@id)
2110
+ end
2111
+ end
2112
+ alias first_child firstchild
2113
+
2114
+ def hasbutton(st=None)
2115
+ if st == None
2116
+ @tree.item_hasbutton(@id)
2117
+ else
2118
+ @tree.item_hasbutton(@id, st)
2119
+ self
2120
+ end
2121
+ end
2122
+ alias has_button hasbutton
2123
+
2124
+ def hasbutton?
2125
+ @tree.item_hasbutton(@id)
2126
+ end
2127
+ alias has_button? hasbutton?
2128
+
2129
+ def index
2130
+ @tree.item_index(@id)
2131
+ end
2132
+
2133
+ def isancestor(des)
2134
+ @tree.item_isancestor(@id, des)
2135
+ end
2136
+ alias is_ancestor isancestor
2137
+ alias isancestor? isancestor
2138
+ alias is_ancestor? isancestor
2139
+ alias ancestor? isancestor
2140
+
2141
+ def isopen
2142
+ @tree.item_isopen(@id)
2143
+ end
2144
+ alias is_open isopen
2145
+ alias isopen? isopen
2146
+ alias is_open? isopen
2147
+ alias isopened? isopen
2148
+ alias is_opened? isopen
2149
+ alias open? isopen
2150
+
2151
+ def lastchild(child=nil)
2152
+ if child
2153
+ @tree.item_lastchild(@id, child)
2154
+ self
2155
+ else
2156
+ @tree.item_lastchild(@id)
2157
+ end
2158
+ end
2159
+ alias last_child lastchild
2160
+
2161
+ def nextsibling(nxt=nil)
2162
+ if nxt
2163
+ @tree.item_nextsibling(@id, nxt)
2164
+ self
2165
+ else
2166
+ @tree.item_nextsibling(@id)
2167
+ end
2168
+ end
2169
+ alias next_sibling nextsibling
2170
+
2171
+ def numchildren
2172
+ @tree.item_numchildren(@id)
2173
+ end
2174
+ alias num_children numchildren
2175
+ alias children_size numchildren
2176
+
2177
+ def parent_index
2178
+ @tree.item_parent(@id)
2179
+ end
2180
+
2181
+ def prevsibling(nxt=nil)
2182
+ if nxt
2183
+ @tree.item_prevsibling(@id, nxt)
2184
+ self
2185
+ else
2186
+ @tree.item_prevsibling(@id)
2187
+ end
2188
+ end
2189
+ alias prev_sibling prevsibling
2190
+
2191
+ def remove
2192
+ @tree.item_remove(@id)
2193
+ end
2194
+
2195
+ def rnc
2196
+ @tree.item_rnc(@id)
2197
+ end
2198
+
2199
+ def sort(*opts)
2200
+ @tree.item_sort(@id, *opts)
2201
+ end
2202
+ def sort_not_really(*opts)
2203
+ @tree.item_sort_not_really(@id, *opts)
2204
+ self
2205
+ end
2206
+
2207
+ def state_forcolumn(column, *args)
2208
+ @tree.item_state_forcolumn(@id, column, *args)
2209
+ self
2210
+ end
2211
+ alias state_for_column state_forcolumn
2212
+
2213
+ def state_get(*args)
2214
+ @tree.item_state_get(@id, *args)
2215
+ end
2216
+
2217
+ def state_set(*args)
2218
+ @tree.item_state_set(@id, *args)
2219
+ self
2220
+ end
2221
+
2222
+ def style_elements(column)
2223
+ @tree.item_style_elements(@id, column)
2224
+ end
2225
+
2226
+ def style_map(column, style, map)
2227
+ @tree.item_style_map(@id, column, style, map)
2228
+ self
2229
+ end
2230
+
2231
+ def style_set(column=nil, *args)
2232
+ if args.empty?
2233
+ @tree.item_style_set(@id, column)
2234
+ else
2235
+ @tree.item_style_set(@id, column, *args)
2236
+ self
2237
+ end
2238
+ end
2239
+
2240
+ def item_text(column, txt=nil, *args)
2241
+ if args.empty?
2242
+ if txt
2243
+ @tree.item_text(@id, column, txt)
2244
+ self
2245
+ else
2246
+ @tree.item_text(@id, column)
2247
+ end
2248
+ else
2249
+ @tree.item_text(@id, column, txt, *args)
2250
+ self
2251
+ end
2252
+ end
2253
+
2254
+ def toggle
2255
+ @tree.item_toggle(@id)
2256
+ self
2257
+ end
2258
+
2259
+ def toggle_recurse
2260
+ @tree.item_toggle_recurse(@id)
2261
+ self
2262
+ end
2263
+
2264
+ def visible(st=None)
2265
+ if st == None
2266
+ @tree.item_visible(@id)
2267
+ else
2268
+ @tree.item_visible(@id, st)
2269
+ self
2270
+ end
2271
+ end
2272
+ end
2273
+
2274
+ #####################
2275
+
2276
+ class Tk::TreeCtrl::Style < TkObject
2277
+ TreeCtrlStyleID_TBL = TkCore::INTERP.create_table
2278
+
2279
+ (TreeCtrlStyleID = ['treectrl_style'.freeze, TkUtil.untrust('00000')]).instance_eval{
2280
+ @mutex = Mutex.new
2281
+ def mutex; @mutex; end
2282
+ freeze
2283
+ }
2284
+
2285
+ TkCore::INTERP.init_ip_env{
2286
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
2287
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear
2288
+ }
2289
+ }
2290
+
2291
+ def self.id2obj(tree, id)
2292
+ tpath = tree.path
2293
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
2294
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
2295
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
2296
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
2297
+ else
2298
+ id
2299
+ end
2300
+ }
2301
+ end
2302
+
2303
+ def initialize(parent, keys=nil)
2304
+ @tree = parent
2305
+ @tpath = parent.path
2306
+
2307
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.mutex.synchronize{
2308
+ @path = @id =
2309
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
2310
+ Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
2311
+ }
2312
+
2313
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
2314
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] ||= {}
2315
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
2316
+ }
2317
+
2318
+ @tree.style_create(@id, keys)
2319
+ end
2320
+
2321
+ def id
2322
+ @id
2323
+ end
2324
+
2325
+ def to_s
2326
+ @id.dup
2327
+ end
2328
+
2329
+ def cget_tkstring(opt)
2330
+ @tree.style_cget_tkstring(@id, opt)
2331
+ end
2332
+ def cget(opt)
2333
+ @tree.style_cget(@id, opt)
2334
+ end
2335
+ def cget_strict(opt)
2336
+ @tree.style_cget_strict(@id, opt)
2337
+ end
2338
+
2339
+ def configure(*args)
2340
+ @tree.style_configure(@id, *args)
2341
+ end
2342
+
2343
+ def configinfo(*args)
2344
+ @tree.style_configinfo(@id, *args)
2345
+ end
2346
+
2347
+ def current_configinfo(*args)
2348
+ @tree.current_style_configinfo(@id, *args)
2349
+ end
2350
+
2351
+ def delete
2352
+ @tree.style_delete(@id)
2353
+ self
2354
+ end
2355
+
2356
+ def elements(*elems)
2357
+ if elems.empty?
2358
+ @tree.style_elements(@id)
2359
+ else
2360
+ @tree.style_elements(@id, *elems)
2361
+ self
2362
+ end
2363
+ end
2364
+
2365
+ def layout(elem, keys=None)
2366
+ if keys && keys != None && keys.kind_of?(Hash)
2367
+ @tree.style_layout(@id, elem, keys)
2368
+ self
2369
+ else
2370
+ @tree.style_layout(@id, elem, keys)
2371
+ end
2372
+ end
2373
+ end
2374
+
2375
+ module Tk::TreeCtrl::BindCallback
2376
+ include Tk
2377
+ extend Tk
2378
+ end
2379
+
2380
+ class << Tk::TreeCtrl::BindCallback
2381
+ def percentsCmd(*args)
2382
+ tk_call('::TreeCtrl::PercentsCmd', *args)
2383
+ end
2384
+ def cursorCheck(w, x, y)
2385
+ tk_call('::TreeCtrl::CursorCheck', w, x, y)
2386
+ end
2387
+ def cursorCheckAux(w)
2388
+ tk_call('::TreeCtrl::CursorCheckAux', w)
2389
+ end
2390
+ def cursorCancel(w)
2391
+ tk_call('::TreeCtrl::CursorCancel', w)
2392
+ end
2393
+ def buttonPress1(w, x, y)
2394
+ tk_call('::TreeCtrl::ButtonPress1', w, x, y)
2395
+ end
2396
+ def doubleButton1(w, x, y)
2397
+ tk_call('::TreeCtrl::DoubleButton1', w, x, y)
2398
+ end
2399
+ def motion1(w, x, y)
2400
+ tk_call('::TreeCtrl::Motion1', w, x, y)
2401
+ end
2402
+ def leave1(w, x, y)
2403
+ tk_call('::TreeCtrl::Leave1', w, x, y)
2404
+ end
2405
+ def release1(w, x, y)
2406
+ tk_call('::TreeCtrl::Release1', w, x, y)
2407
+ end
2408
+ def beginSelect(w, el)
2409
+ tk_call('::TreeCtrl::BeginSelect', w, el)
2410
+ end
2411
+ def motion(w, le)
2412
+ tk_call('::TreeCtrl::Motion', w, el)
2413
+ end
2414
+ def beginExtend(w, el)
2415
+ tk_call('::TreeCtrl::BeginExtend', w, el)
2416
+ end
2417
+ def beginToggle(w, el)
2418
+ tk_call('::TreeCtrl::BeginToggle', w, el)
2419
+ end
2420
+ def cancelRepeat
2421
+ tk_call('::TreeCtrl::CancelRepeat')
2422
+ end
2423
+ def autoScanCheck(w, x, y)
2424
+ tk_call('::TreeCtrl::AutoScanCheck', w, x, y)
2425
+ end
2426
+ def autoScanCheckAux(w)
2427
+ tk_call('::TreeCtrl::AutoScanCheckAux', w)
2428
+ end
2429
+ def autoScanCancel(w)
2430
+ tk_call('::TreeCtrl::AutoScanCancel', w)
2431
+ end
2432
+ def up_down(w, n)
2433
+ tk_call('::TreeCtrl::UpDown', w, n)
2434
+ end
2435
+ def left_right(w, n)
2436
+ tk_call('::TreeCtrl::LeftRight', w, n)
2437
+ end
2438
+ def setActiveItem(w, idx)
2439
+ tk_call('::TreeCtrl::SetActiveItem', w, idx)
2440
+ end
2441
+ def extendUpDown(w, amount)
2442
+ tk_call('::TreeCtrl::ExtendUpDown', w, amount)
2443
+ end
2444
+ def dataExtend(w, el)
2445
+ tk_call('::TreeCtrl::DataExtend', w, el)
2446
+ end
2447
+ def cancel(w)
2448
+ tk_call('::TreeCtrl::Cancel', w)
2449
+ end
2450
+ def selectAll(w)
2451
+ tk_call('::TreeCtrl::selectAll', w)
2452
+ end
2453
+ def marqueeBegin(w, x, y)
2454
+ tk_call('::TreeCtrl::MarqueeBegin', w, x, y)
2455
+ end
2456
+ def marqueeUpdate(w, x, y)
2457
+ tk_call('::TreeCtrl::MarqueeUpdate', w, x, y)
2458
+ end
2459
+ def marqueeEnd(w, x, y)
2460
+ tk_call('::TreeCtrl::MarqueeEnd', w, x, y)
2461
+ end
2462
+ def scanMark(w, x, y)
2463
+ tk_call('::TreeCtrl::ScanMark', w, x, y)
2464
+ end
2465
+ def scanDrag(w, x, y)
2466
+ tk_call('::TreeCtrl::ScanDrag', w, x, y)
2467
+ end
2468
+
2469
+ # filelist-bindings
2470
+ def fileList_button1(w, x, y)
2471
+ tk_call('::TreeCtrl::FileListButton1', w, x, y)
2472
+ end
2473
+ def fileList_motion1(w, x, y)
2474
+ tk_call('::TreeCtrl::FileListMotion1', w, x, y)
2475
+ end
2476
+ def fileList_motion(w, x, y)
2477
+ tk_call('::TreeCtrl::FileListMotion', w, x, y)
2478
+ end
2479
+ def fileList_leave1(w, x, y)
2480
+ tk_call('::TreeCtrl::FileListLeave1', w, x, y)
2481
+ end
2482
+ def fileList_release1(w, x, y)
2483
+ tk_call('::TreeCtrl::FileListRelease1', w, x, y)
2484
+ end
2485
+ def fileList_edit(w, i, s, e)
2486
+ tk_call('::TreeCtrl::FileListEdit', w, i, s, e)
2487
+ end
2488
+ def fileList_editCancel(w)
2489
+ tk_call('::TreeCtrl::FileListEditCancel', w)
2490
+ end
2491
+ def fileList_autoScanCheck(w, x, y)
2492
+ tk_call('::TreeCtrl::FileListAutoScanCheck', w, x, y)
2493
+ end
2494
+ def fileList_autoScanCheckAux(w)
2495
+ tk_call('::TreeCtrl::FileListAutoScanCheckAux', w)
2496
+ end
2497
+
2498
+ def entryOpen(w, item, col, elem)
2499
+ tk_call('::TreeCtrl::EntryOpen', w, item, col, elem)
2500
+ end
2501
+ def entryExpanderOpen(w, item, col, elem)
2502
+ tk_call('::TreeCtrl::EntryExpanderOpen', w, item, col, elem)
2503
+ end
2504
+ def entryClose(w, accept)
2505
+ tk_call('::TreeCtrl::EntryClose', w, accept)
2506
+ end
2507
+ def entryExpanderKeypress(w)
2508
+ tk_call('::TreeCtrl::EntryExpanderKeypress', w)
2509
+ end
2510
+ def textOpen(w, item, col, elem, width=0, height=0)
2511
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width, height)
2512
+ end
2513
+ def textExpanderOpen(w, item, col, elem, width)
2514
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width)
2515
+ end
2516
+ def textClose(w, accept)
2517
+ tk_call('::TreeCtrl::TextClose', w, accept)
2518
+ end
2519
+ def textExpanderKeypress(w)
2520
+ tk_call('::TreeCtrl::TextExpanderKeypress', w)
2521
+ end
2522
+ end