tk-win 0.2.0-x86-mingw32

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 (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,284 @@
1
+ #
2
+ # tk/listbox.rb : treat listbox widget
3
+ #
4
+ require 'tk'
5
+ require 'tk/itemconfig'
6
+ require 'tk/scrollable'
7
+ require 'tk/txtwin_abst'
8
+
9
+ module TkListItemConfig
10
+ include TkItemConfigMethod
11
+
12
+ def __item_listval_optkeys(id)
13
+ []
14
+ end
15
+ private :__item_listval_optkeys
16
+ end
17
+
18
+ class Tk::Listbox<TkTextWin
19
+ include TkListItemConfig
20
+ include Scrollable
21
+
22
+ TkCommandNames = ['listbox'.freeze].freeze
23
+ WidgetClassName = 'Listbox'.freeze
24
+ WidgetClassNames[WidgetClassName] ||= self
25
+
26
+ #def create_self(keys)
27
+ # if keys and keys != None
28
+ # tk_call_without_enc('listbox', @path, *hash_kv(keys, true))
29
+ # else
30
+ # tk_call_without_enc('listbox', @path)
31
+ # end
32
+ #end
33
+ #private :create_self
34
+
35
+ def __tkvariable_optkeys
36
+ super() << 'listvariable'
37
+ end
38
+ private :__tkvariable_optkeys
39
+
40
+ def tagid(id)
41
+ #id.to_s
42
+ _get_eval_string(id)
43
+ end
44
+
45
+ def activate(y)
46
+ tk_send_without_enc('activate', y)
47
+ self
48
+ end
49
+ def curselection
50
+ list(tk_send_without_enc('curselection'))
51
+ end
52
+ def get(first, last=nil)
53
+ if last
54
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
55
+ tk_split_simplelist(tk_send_without_enc('get', first, last), false, true)
56
+ else
57
+ _fromUTF8(tk_send_without_enc('get', first))
58
+ end
59
+ end
60
+ def nearest(y)
61
+ tk_send_without_enc('nearest', y).to_i
62
+ end
63
+ def size
64
+ tk_send_without_enc('size').to_i
65
+ end
66
+ def selection_anchor(index)
67
+ tk_send_without_enc('selection', 'anchor', index)
68
+ self
69
+ end
70
+ def selection_clear(first, last=None)
71
+ tk_send_without_enc('selection', 'clear', first, last)
72
+ self
73
+ end
74
+ def selection_includes(index)
75
+ bool(tk_send_without_enc('selection', 'includes', index))
76
+ end
77
+ def selection_set(first, last=None)
78
+ tk_send_without_enc('selection', 'set', first, last)
79
+ self
80
+ end
81
+
82
+ def index(idx)
83
+ tk_send_without_enc('index', idx).to_i
84
+ end
85
+
86
+ def value
87
+ get('0', 'end')
88
+ end
89
+
90
+ def value= (vals)
91
+ unless vals.kind_of?(Array)
92
+ fail ArgumentError, 'an Array is expected'
93
+ end
94
+ tk_send_without_enc('delete', '0', 'end')
95
+ tk_send_without_enc('insert', '0',
96
+ *(vals.collect{|v| _get_eval_enc_str(v)}))
97
+ vals
98
+ end
99
+
100
+ def clear
101
+ tk_send_without_enc('delete', '0', 'end')
102
+ self
103
+ end
104
+ alias erase clear
105
+
106
+ =begin
107
+ def itemcget(index, key)
108
+ case key.to_s
109
+ when 'text', 'label', 'show'
110
+ _fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}"))
111
+ when 'font', 'kanjifont'
112
+ #fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}"))
113
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index,
114
+ '-font')))
115
+ unless fnt.kind_of?(TkFont)
116
+ fnt = tagfontobj(index, fnt)
117
+ end
118
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
119
+ # obsolete; just for compatibility
120
+ fnt.kanji_font
121
+ else
122
+ fnt
123
+ end
124
+ else
125
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")))
126
+ end
127
+ end
128
+ def itemconfigure(index, key, val=None)
129
+ if key.kind_of? Hash
130
+ if (key['font'] || key[:font] ||
131
+ key['kanjifont'] || key[:kanjifont] ||
132
+ key['latinfont'] || key[:latinfont] ||
133
+ key['asciifont'] || key[:asciifont] )
134
+ tagfont_configure(index, _symbolkey2str(key))
135
+ else
136
+ tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
137
+ end
138
+
139
+ else
140
+ if (key == 'font' || key == :font ||
141
+ key == 'kanjifont' || key == :kanjifont ||
142
+ key == 'latinfont' || key == :latinfont ||
143
+ key == 'asciifont' || key == :asciifont )
144
+ if val == None
145
+ tagfontobj(index)
146
+ else
147
+ tagfont_configure(index, {key=>val})
148
+ end
149
+ else
150
+ tk_call('itemconfigure', index, "-#{key}", val)
151
+ end
152
+ end
153
+ self
154
+ end
155
+
156
+ def itemconfiginfo(index, key=nil)
157
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
158
+ if key
159
+ case key.to_s
160
+ when 'text', 'label', 'show'
161
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
162
+ when 'font', 'kanjifont'
163
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
164
+ conf[4] = tagfont_configinfo(index, conf[4])
165
+ else
166
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
167
+ end
168
+ conf[0] = conf[0][1..-1]
169
+ conf
170
+ else
171
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
172
+ conf = tk_split_simplelist(conflist)
173
+ conf[0] = conf[0][1..-1]
174
+ case conf[0]
175
+ when 'text', 'label', 'show'
176
+ else
177
+ if conf[3]
178
+ if conf[3].index('{')
179
+ conf[3] = tk_split_list(conf[3])
180
+ else
181
+ conf[3] = tk_tcl2ruby(conf[3])
182
+ end
183
+ end
184
+ if conf[4]
185
+ if conf[4].index('{')
186
+ conf[4] = tk_split_list(conf[4])
187
+ else
188
+ conf[4] = tk_tcl2ruby(conf[4])
189
+ end
190
+ end
191
+ end
192
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
193
+ conf
194
+ }
195
+ fontconf = ret.assoc('font')
196
+ if fontconf
197
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
198
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
199
+ ret.push(fontconf)
200
+ else
201
+ ret
202
+ end
203
+ end
204
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
205
+ if key
206
+ case key.to_s
207
+ when 'text', 'label', 'show'
208
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
209
+ when 'font', 'kanjifont'
210
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
211
+ conf[4] = tagfont_configinfo(index, conf[4])
212
+ else
213
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
214
+ end
215
+ key = conf.shift[1..-1]
216
+ { key => conf }
217
+ else
218
+ ret = {}
219
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
220
+ conf = tk_split_simplelist(conflist)
221
+ key = conf.shift[1..-1]
222
+ case key
223
+ when 'text', 'label', 'show'
224
+ else
225
+ if conf[2]
226
+ if conf[2].index('{')
227
+ conf[2] = tk_split_list(conf[2])
228
+ else
229
+ conf[2] = tk_tcl2ruby(conf[2])
230
+ end
231
+ end
232
+ if conf[3]
233
+ if conf[3].index('{')
234
+ conf[3] = tk_split_list(conf[3])
235
+ else
236
+ conf[3] = tk_tcl2ruby(conf[3])
237
+ end
238
+ end
239
+ end
240
+ if conf.size == 1
241
+ ret[key] = conf[0][1..-1] # alias info
242
+ else
243
+ ret[key] = conf
244
+ end
245
+ }
246
+ fontconf = ret['font']
247
+ if fontconf
248
+ ret.delete('font')
249
+ ret.delete('kanjifont')
250
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
251
+ ret['font'] = fontconf
252
+ end
253
+ ret
254
+ end
255
+ end
256
+ end
257
+
258
+ def current_itemconfiginfo(index, key=nil)
259
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
260
+ if key
261
+ conf = itemconfiginfo(index, key)
262
+ {conf[0] => conf[4]}
263
+ else
264
+ ret = {}
265
+ itemconfiginfo(index).each{|conf|
266
+ ret[conf[0]] = conf[4] if conf.size > 2
267
+ }
268
+ ret
269
+ end
270
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
271
+ ret = {}
272
+ itemconfiginfo(index, key).each{|k, conf|
273
+ ret[k] = conf[-1] if conf.kind_of?(Array)
274
+ }
275
+ ret
276
+ end
277
+ end
278
+ =end
279
+ end
280
+
281
+ #TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox
282
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::Listbox, :TkListbox)
283
+ Tk.__set_loaded_toplevel_aliases__('tk/listbox.rb', :Tk, Tk::Listbox,
284
+ :TkListbox)
@@ -0,0 +1,80 @@
1
+ #
2
+ # tk/macpkg.rb : methods for Tcl/Tk packages for Macintosh
3
+ # 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
4
+ #
5
+ # ATTENTION !!
6
+ # This is NOT TESTED. Because I have no test-environment.
7
+ #
8
+ #
9
+ require 'tk'
10
+
11
+ module Tk
12
+ def Tk.load_tclscript_rsrc(resource_name, file=None)
13
+ # Mac only
14
+ tk_call('source', '-rsrc', resource_name, file)
15
+ end
16
+
17
+ def Tk.load_tclscript_rsrcid(resource_id, file=None)
18
+ # Mac only
19
+ tk_call('source', '-rsrcid', resource_id, file)
20
+ end
21
+ end
22
+
23
+ module Tk::MacResource
24
+ end
25
+ #TkMacResource = Tk::MacResource
26
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::MacResource, :TkMacResource)
27
+ Tk.__set_loaded_toplevel_aliases__('tk/macpkg.rb', :Tk, Tk::MacResource,
28
+ :TkMacResource)
29
+
30
+ module Tk::MacResource
31
+ extend Tk
32
+ extend Tk::MacResource
33
+
34
+ TkCommandNames = ['resource'.freeze].freeze
35
+
36
+ PACKAGE_NAME = 'resource'.freeze
37
+ def self.package_name
38
+ PACKAGE_NAME
39
+ end
40
+
41
+ tk_call_without_enc('package', 'require', 'resource')
42
+
43
+ def close(rsrcRef)
44
+ tk_call('resource', 'close', rsrcRef)
45
+ end
46
+
47
+ def delete(rsrcType, opts=nil)
48
+ tk_call('resource', 'delete', *(hash_kv(opts) << rsrcType))
49
+ end
50
+
51
+ def files(rsrcRef=nil)
52
+ if rsrcRef
53
+ tk_call('resource', 'files', rsrcRef)
54
+ else
55
+ tk_split_simplelist(tk_call('resource', 'files'))
56
+ end
57
+ end
58
+
59
+ def list(rsrcType, rsrcRef=nil)
60
+ tk_split_simplelist(tk_call('resource', 'list', rsrcType, rsrcRef))
61
+ end
62
+
63
+ def open(fname, access=nil)
64
+ tk_call('resource', 'open', fname, access)
65
+ end
66
+
67
+ def read(rsrcType, rsrcID, rsrcRef=nil)
68
+ tk_call('resource', 'read', rsrcType, rsrcID, rsrcRef)
69
+ end
70
+
71
+ def types(rsrcRef=nil)
72
+ tk_split_simplelist(tk_call('resource', 'types', rsrcRef))
73
+ end
74
+
75
+ def write(rsrcType, data, opts=nil)
76
+ tk_call('resource', 'write', *(hash_kv(opts) << rsrcType << data))
77
+ end
78
+
79
+ module_function :close, :delete, :files, :list, :open, :read, :types, :write
80
+ end
@@ -0,0 +1,718 @@
1
+ #
2
+ # tk/menu.rb : treat menu and menubutton
3
+ #
4
+ require 'tk'
5
+ require 'tk/itemconfig'
6
+ require 'tk/menuspec'
7
+
8
+ module TkMenuEntryConfig
9
+ include TkItemConfigMethod
10
+
11
+ def __item_cget_cmd(id)
12
+ [self.path, 'entrycget', id]
13
+ end
14
+ private :__item_cget_cmd
15
+
16
+ def __item_config_cmd(id)
17
+ [self.path, 'entryconfigure', id]
18
+ end
19
+ private :__item_config_cmd
20
+
21
+ def __item_strval_optkeys(id)
22
+ super(id) << 'selectcolor'
23
+ end
24
+ private :__item_strval_optkeys
25
+
26
+ def __item_listval_optkeys(id)
27
+ []
28
+ end
29
+ private :__item_listval_optkeys
30
+
31
+ def __item_val2ruby_optkeys(id) # { key=>proc, ... }
32
+ super(id).update('menu'=>proc{|i, v| window(v)})
33
+ end
34
+ private :__item_val2ruby_optkeys
35
+
36
+ alias entrycget_tkstring itemcget_tkstring
37
+ alias entrycget itemcget
38
+ alias entrycget_strict itemcget_strict
39
+ alias entryconfigure itemconfigure
40
+ alias entryconfiginfo itemconfiginfo
41
+ alias current_entryconfiginfo current_itemconfiginfo
42
+
43
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
44
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
45
+ end
46
+
47
+ class Tk::Menu<TkWindow
48
+ include Wm
49
+ include TkMenuEntryConfig
50
+ extend TkMenuSpec
51
+
52
+ TkCommandNames = ['menu'.freeze].freeze
53
+ WidgetClassName = 'Menu'.freeze
54
+ WidgetClassNames[WidgetClassName] ||= self
55
+
56
+ #def create_self(keys)
57
+ # if keys and keys != None
58
+ # tk_call_without_enc('menu', @path, *hash_kv(keys, true))
59
+ # else
60
+ # tk_call_without_enc('menu', @path)
61
+ # end
62
+ #end
63
+ #private :create_self
64
+
65
+ def __strval_optkeys
66
+ super() << 'selectcolor' << 'title'
67
+ end
68
+ private :__strval_optkeys
69
+
70
+ def __boolval_optkeys
71
+ super() << 'tearoff'
72
+ end
73
+ private :__boolval_optkeys
74
+
75
+ def self.new_menuspec(menu_spec, parent = nil, tearoff = false, keys = nil)
76
+ if parent.kind_of?(Hash)
77
+ keys = _symbolkey2str(parent)
78
+ parent = keys.delete('parent')
79
+ tearoff = keys.delete('tearoff')
80
+ elsif tearoff.kind_of?(Hash)
81
+ keys = _symbolkey2str(tearoff)
82
+ tearoff = keys.delete('tearoff')
83
+ elsif keys
84
+ keys = _symbolkey2str(keys)
85
+ else
86
+ keys = {}
87
+ end
88
+
89
+ widgetname = keys.delete('widgetname')
90
+ _create_menu(parent, menu_spec, widgetname, tearoff, keys)
91
+ end
92
+
93
+ def tagid(id)
94
+ #id.to_s
95
+ _get_eval_string(id)
96
+ end
97
+
98
+ def activate(index)
99
+ tk_send_without_enc('activate', _get_eval_enc_str(index))
100
+ self
101
+ end
102
+ def add(type, keys=nil)
103
+ tk_send_without_enc('add', type, *hash_kv(keys, true))
104
+ self
105
+ end
106
+ def add_cascade(keys=nil)
107
+ add('cascade', keys)
108
+ end
109
+ def add_checkbutton(keys=nil)
110
+ add('checkbutton', keys)
111
+ end
112
+ def add_command(keys=nil)
113
+ add('command', keys)
114
+ end
115
+ def add_radiobutton(keys=nil)
116
+ add('radiobutton', keys)
117
+ end
118
+ def add_separator(keys=nil)
119
+ add('separator', keys)
120
+ end
121
+
122
+ def clone_menu(*args)
123
+ if args[0].kind_of?(TkWindow)
124
+ parent = args.shift
125
+ else
126
+ parent = self
127
+ end
128
+
129
+ if args[0].kind_of?(String) || args[0].kind_of?(Symbol) # menu type
130
+ type = args.shift
131
+ else
132
+ type = None # 'normal'
133
+ end
134
+
135
+ if args[0].kind_of?(Hash)
136
+ keys = _symbolkey2str(args.shift)
137
+ else
138
+ keys = {}
139
+ end
140
+
141
+ parent = keys.delete('parent') if keys.has_key?('parent')
142
+ type = keys.delete('type') if keys.has_key?('type')
143
+
144
+ if keys.empty?
145
+ Tk::MenuClone.new(self, parent, type)
146
+ else
147
+ Tk::MenuClone.new(self, parent, type, keys)
148
+ end
149
+ end
150
+
151
+ def index(idx)
152
+ ret = tk_send_without_enc('index', _get_eval_enc_str(idx))
153
+ (ret == 'none')? nil: number(ret)
154
+ end
155
+ def invoke(index)
156
+ _fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
157
+ end
158
+ def insert(index, type, keys=nil)
159
+ tk_send_without_enc('insert', _get_eval_enc_str(index),
160
+ type, *hash_kv(keys, true))
161
+ self
162
+ end
163
+ def delete(first, last=nil)
164
+ if last
165
+ tk_send_without_enc('delete', _get_eval_enc_str(first),
166
+ _get_eval_enc_str(last))
167
+ else
168
+ tk_send_without_enc('delete', _get_eval_enc_str(first))
169
+ end
170
+ self
171
+ end
172
+ def popup(x, y, index=nil)
173
+ if index
174
+ tk_call_without_enc('tk_popup', path, x, y,
175
+ _get_eval_enc_str(index))
176
+ else
177
+ tk_call_without_enc('tk_popup', path, x, y)
178
+ end
179
+ self
180
+ end
181
+ def post(x, y)
182
+ _fromUTF8(tk_send_without_enc('post', x, y))
183
+ end
184
+ def postcascade(index)
185
+ tk_send_without_enc('postcascade', _get_eval_enc_str(index))
186
+ self
187
+ end
188
+ def postcommand(cmd=Proc.new)
189
+ configure_cmd 'postcommand', cmd
190
+ self
191
+ end
192
+ def set_focus
193
+ tk_call_without_enc('tk_menuSetFocus', path)
194
+ self
195
+ end
196
+ def tearoffcommand(cmd=Proc.new)
197
+ configure_cmd 'tearoffcommand', cmd
198
+ self
199
+ end
200
+ def menutype(index)
201
+ tk_send_without_enc('type', _get_eval_enc_str(index))
202
+ end
203
+ def unpost
204
+ tk_send_without_enc('unpost')
205
+ self
206
+ end
207
+ def xposition(index)
208
+ number(tk_send_without_enc('xposition', _get_eval_enc_str(index)))
209
+ end
210
+ def yposition(index)
211
+ number(tk_send_without_enc('yposition', _get_eval_enc_str(index)))
212
+ end
213
+
214
+ =begin
215
+ def entrycget(index, key)
216
+ case key.to_s
217
+ when 'text', 'label', 'show'
218
+ _fromUTF8(tk_send_without_enc('entrycget',
219
+ _get_eval_enc_str(index), "-#{key}"))
220
+ when 'font', 'kanjifont'
221
+ #fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
222
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), '-font')))
223
+ unless fnt.kind_of?(TkFont)
224
+ fnt = tagfontobj(index, fnt)
225
+ end
226
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
227
+ # obsolete; just for compatibility
228
+ fnt.kanji_font
229
+ else
230
+ fnt
231
+ end
232
+ else
233
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), "-#{key}")))
234
+ end
235
+ end
236
+ def entryconfigure(index, key, val=None)
237
+ if key.kind_of? Hash
238
+ if (key['font'] || key[:font] ||
239
+ key['kanjifont'] || key[:kanjifont] ||
240
+ key['latinfont'] || key[:latinfont] ||
241
+ key['asciifont'] || key[:asciifont])
242
+ tagfont_configure(index, _symbolkey2str(key))
243
+ else
244
+ tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
245
+ *hash_kv(key, true))
246
+ end
247
+
248
+ else
249
+ if (key == 'font' || key == :font ||
250
+ key == 'kanjifont' || key == :kanjifont ||
251
+ key == 'latinfont' || key == :latinfont ||
252
+ key == 'asciifont' || key == :asciifont )
253
+ if val == None
254
+ tagfontobj(index)
255
+ else
256
+ tagfont_configure(index, {key=>val})
257
+ end
258
+ else
259
+ tk_call('entryconfigure', index, "-#{key}", val)
260
+ end
261
+ end
262
+ self
263
+ end
264
+
265
+ def entryconfiginfo(index, key=nil)
266
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
267
+ if key
268
+ case key.to_s
269
+ when 'text', 'label', 'show'
270
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
271
+ when 'font', 'kanjifont'
272
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
273
+ conf[4] = tagfont_configinfo(index, conf[4])
274
+ else
275
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
276
+ end
277
+ conf[0] = conf[0][1..-1]
278
+ conf
279
+ else
280
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
281
+ conf = tk_split_simplelist(conflist)
282
+ conf[0] = conf[0][1..-1]
283
+ case conf[0]
284
+ when 'text', 'label', 'show'
285
+ else
286
+ if conf[3]
287
+ if conf[3].index('{')
288
+ conf[3] = tk_split_list(conf[3])
289
+ else
290
+ conf[3] = tk_tcl2ruby(conf[3])
291
+ end
292
+ end
293
+ if conf[4]
294
+ if conf[4].index('{')
295
+ conf[4] = tk_split_list(conf[4])
296
+ else
297
+ conf[4] = tk_tcl2ruby(conf[4])
298
+ end
299
+ end
300
+ end
301
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
302
+ conf
303
+ }
304
+ if fontconf
305
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
306
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
307
+ ret.push(fontconf)
308
+ else
309
+ ret
310
+ end
311
+ end
312
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
313
+ if key
314
+ case key.to_s
315
+ when 'text', 'label', 'show'
316
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
317
+ when 'font', 'kanjifont'
318
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
319
+ conf[4] = tagfont_configinfo(index, conf[4])
320
+ else
321
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
322
+ end
323
+ key = conf.shift[1..-1]
324
+ { key => conf }
325
+ else
326
+ ret = {}
327
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
328
+ conf = tk_split_simplelist(conflist)
329
+ key = conf.shift[1..-1]
330
+ case key
331
+ when 'text', 'label', 'show'
332
+ else
333
+ if conf[2]
334
+ if conf[2].index('{')
335
+ conf[2] = tk_split_list(conf[2])
336
+ else
337
+ conf[2] = tk_tcl2ruby(conf[2])
338
+ end
339
+ end
340
+ if conf[3]
341
+ if conf[3].index('{')
342
+ conf[3] = tk_split_list(conf[3])
343
+ else
344
+ conf[3] = tk_tcl2ruby(conf[3])
345
+ end
346
+ end
347
+ end
348
+ if conf.size == 1
349
+ ret[key] = conf[0][1..-1] # alias info
350
+ else
351
+ ret[key] = conf
352
+ end
353
+ }
354
+ fontconf = ret['font']
355
+ if fontconf
356
+ ret.delete('font')
357
+ ret.delete('kanjifont')
358
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
359
+ ret['font'] = fontconf
360
+ end
361
+ ret
362
+ end
363
+ end
364
+ end
365
+
366
+ def current_entryconfiginfo(index, key=nil)
367
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
368
+ if key
369
+ conf = entryconfiginfo(index, key)
370
+ {conf[0] => conf[4]}
371
+ else
372
+ ret = {}
373
+ entryconfiginfo(index).each{|conf|
374
+ ret[conf[0]] = conf[4] if conf.size > 2
375
+ }
376
+ ret
377
+ end
378
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
379
+ ret = {}
380
+ entryconfiginfo(index, key).each{|k, conf|
381
+ ret[k] = conf[-1] if conf.kind_of?(Array)
382
+ }
383
+ ret
384
+ end
385
+ end
386
+ =end
387
+ end
388
+
389
+ #TkMenu = Tk::Menu unless Object.const_defined? :TkMenu
390
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::Menu, :TkMenu)
391
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::Menu, :TkMenu)
392
+
393
+
394
+ module Tk::Menu::TkInternalFunction; end
395
+ class << Tk::Menu::TkInternalFunction
396
+ # These methods calls internal functions of Tcl/Tk.
397
+ # So, They may not work on your Tcl/Tk.
398
+ def next_menu(menu, dir='next')
399
+ dir = dir.to_s
400
+ case dir
401
+ when 'next', 'forward', 'down'
402
+ dir = 'right'
403
+ when 'previous', 'backward', 'up'
404
+ dir = 'left'
405
+ end
406
+
407
+ Tk.tk_call('::tk::MenuNextMenu', menu, dir)
408
+ end
409
+
410
+ def next_entry(menu, delta)
411
+ # delta is increment value of entry index.
412
+ # For example, +1 denotes 'next entry' and -1 denotes 'previous entry'.
413
+ Tk.tk_call('::tk::MenuNextEntry', menu, delta)
414
+ end
415
+ end
416
+
417
+ class Tk::MenuClone<Tk::Menu
418
+ =begin
419
+ def initialize(parent, type=None)
420
+ widgetname = nil
421
+ if parent.kind_of? Hash
422
+ keys = _symbolkey2str(parent)
423
+ parent = keys.delete('parent')
424
+ widgetname = keys.delete('widgetname')
425
+ type = keys.delete('type'); type = None unless type
426
+ end
427
+ #unless parent.kind_of?(TkMenu)
428
+ # fail ArgumentError, "parent must be TkMenu"
429
+ #end
430
+ @parent = parent
431
+ install_win(@parent.path, widgetname)
432
+ tk_call_without_enc(@parent.path, 'clone', @path, type)
433
+ end
434
+ =end
435
+ def initialize(src_menu, *args)
436
+ widgetname = nil
437
+
438
+ if args[0].kind_of?(TkWindow) # parent window
439
+ parent = args.shift
440
+ else
441
+ parent = src_menu
442
+ end
443
+
444
+ if args[0].kind_of?(String) || args[0].kind_of?(Symbol) # menu type
445
+ type = args.shift
446
+ else
447
+ type = None # 'normal'
448
+ end
449
+
450
+ if args[0].kind_of?(Hash)
451
+ keys = _symbolkey2str(args.shift)
452
+ parent = keys.delete('parent') if keys.has_key?('parent')
453
+ widgetname = keys.delete('widgetname')
454
+ type = keys.delete('type') if keys.has_key?('type')
455
+ else
456
+ keys = nil
457
+ end
458
+
459
+ @src_menu = src_menu
460
+ @parent = parent
461
+ @type = type
462
+ install_win(@parent.path, widgetname)
463
+ tk_call_without_enc(@src_menu.path, 'clone', @path, @type)
464
+ configure(keys) if keys && !keys.empty?
465
+ end
466
+
467
+ def source_menu
468
+ @src_menu
469
+ end
470
+ end
471
+ Tk::CloneMenu = Tk::MenuClone
472
+ #TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone
473
+ #TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu
474
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::MenuClone, :TkMenuClone, :TkCloneMenu)
475
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::MenuClone,
476
+ :TkMenuClone, :TkCloneMenu)
477
+
478
+ module Tk::SystemMenu
479
+ def initialize(parent, keys=nil)
480
+ if parent.kind_of? Hash
481
+ keys = _symbolkey2str(parent)
482
+ parent = keys.delete('parent')
483
+ end
484
+ #unless parent.kind_of? TkMenu
485
+ # fail ArgumentError, "parent must be a TkMenu object"
486
+ #end
487
+ # @path = Kernel.format("%s.%s", parent.path, self.class::SYSMENU_NAME)
488
+ @path = parent.path + '.' + self.class::SYSMENU_NAME
489
+ #TkComm::Tk_WINDOWS[@path] = self
490
+ TkCore::INTERP.tk_windows[@path] = self
491
+ if self.method(:create_self).arity == 0
492
+ p 'create_self has no arg' if $DEBUG
493
+ create_self
494
+ configure(keys) if keys
495
+ else
496
+ p 'create_self has an arg' if $DEBUG
497
+ create_self(keys)
498
+ end
499
+ end
500
+ end
501
+ TkSystemMenu = Tk::SystemMenu
502
+
503
+
504
+ class Tk::SysMenu_Help<Tk::Menu
505
+ # for all platform
506
+ include Tk::SystemMenu
507
+ SYSMENU_NAME = 'help'
508
+ end
509
+ #TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help
510
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Help, :TkSysMenu_Help)
511
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_Help,
512
+ :TkSysMenu_Help)
513
+
514
+
515
+ class Tk::SysMenu_System<Tk::Menu
516
+ # for Windows
517
+ include Tk::SystemMenu
518
+ SYSMENU_NAME = 'system'
519
+ end
520
+ #TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System
521
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_System, :TkSysMenu_System)
522
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_System,
523
+ :TkSysMenu_System)
524
+
525
+
526
+ class Tk::SysMenu_Apple<Tk::Menu
527
+ # for Machintosh
528
+ include Tk::SystemMenu
529
+ SYSMENU_NAME = 'apple'
530
+ end
531
+ #TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple
532
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Apple, :TkSysMenu_Apple)
533
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_Apple,
534
+ :TkSysMenu_Apple)
535
+
536
+
537
+ class Tk::Menubutton<Tk::Label
538
+ TkCommandNames = ['menubutton'.freeze].freeze
539
+ WidgetClassName = 'Menubutton'.freeze
540
+ WidgetClassNames[WidgetClassName] ||= self
541
+ def create_self(keys)
542
+ if keys and keys != None
543
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
544
+ # tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
545
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
546
+ *hash_kv(keys, true))
547
+ else
548
+ begin
549
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
550
+ *hash_kv(keys, true))
551
+ rescue
552
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
553
+ keys = __check_available_configure_options(keys)
554
+ unless keys.empty?
555
+ tk_call_without_enc('destroy', @path) rescue nil
556
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
557
+ *hash_kv(keys, true))
558
+ end
559
+ end
560
+ end
561
+ else
562
+ # tk_call_without_enc('menubutton', @path)
563
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
564
+ end
565
+ end
566
+ private :create_self
567
+
568
+ def __boolval_optkeys
569
+ super() << 'indicatoron'
570
+ end
571
+ private :__boolval_optkeys
572
+
573
+ end
574
+ Tk::MenuButton = Tk::Menubutton
575
+ #TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton
576
+ #TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton
577
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::Menubutton, :TkMenubutton, :TkMenuButton)
578
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::Menubutton,
579
+ :TkMenubutton, :TkMenuButton)
580
+
581
+
582
+ class Tk::OptionMenubutton<Tk::Menubutton
583
+ TkCommandNames = ['tk_optionMenu'.freeze].freeze
584
+
585
+ class OptionMenu<TkMenu
586
+ def initialize(path) #==> return value of tk_optionMenu
587
+ @path = path
588
+ #TkComm::Tk_WINDOWS[@path] = self
589
+ TkCore::INTERP.tk_windows[@path] = self
590
+ end
591
+ end
592
+
593
+ def initialize(*args)
594
+ # args :: [parent,] [var,] [value[, ...],] [keys]
595
+ # parent --> TkWindow or nil
596
+ # var --> TkVariable or nil
597
+ # keys --> Hash
598
+ # keys[:parent] or keys['parent'] --> parent
599
+ # keys[:variable] or keys['variable'] --> var
600
+ # keys[:values] or keys['values'] --> value, ...
601
+ # other Hash keys are menubutton options
602
+ keys = {}
603
+ keys = args.pop if args[-1].kind_of?(Hash)
604
+ keys = _symbolkey2str(keys)
605
+
606
+ parent = nil
607
+ if !args.empty? && (args[0].kind_of?(TkWindow) || args[0] == nil)
608
+ keys.delete('parent') # ignore
609
+ parent = args.shift
610
+ else
611
+ parent = keys.delete('parent')
612
+ end
613
+
614
+ @variable = nil
615
+ if !args.empty? && (args[0].kind_of?(TkVariable) || args[0] == nil)
616
+ keys.delete('variable') # ignore
617
+ @variable = args.shift
618
+ else
619
+ @variable = keys.delete('variable')
620
+ end
621
+ @variable = TkVariable.new unless @variable
622
+
623
+ (args = keys.delete('values') || []) if args.empty?
624
+ if args.empty?
625
+ args << @variable.value
626
+ else
627
+ @variable.value = args[0]
628
+ end
629
+
630
+ install_win(if parent then parent.path end)
631
+ @menu = OptionMenu.new(tk_call('tk_optionMenu',
632
+ @path, @variable.id, *args))
633
+
634
+ configure(keys) if keys
635
+ end
636
+
637
+ def value
638
+ @variable.value
639
+ end
640
+
641
+ def value=(val)
642
+ @variable.value = val
643
+ end
644
+
645
+ def activate(index)
646
+ @menu.activate(index)
647
+ self
648
+ end
649
+ def add(value)
650
+ @menu.add('radiobutton', 'variable'=>@variable,
651
+ 'label'=>value, 'value'=>value)
652
+ self
653
+ end
654
+ def index(index)
655
+ @menu.index(index)
656
+ end
657
+ def invoke(index)
658
+ @menu.invoke(index)
659
+ end
660
+ def insert(index, value)
661
+ @menu.insert(index, 'radiobutton', 'variable'=>@variable,
662
+ 'label'=>value, 'value'=>value)
663
+ self
664
+ end
665
+ def delete(index, last=None)
666
+ @menu.delete(index, last)
667
+ self
668
+ end
669
+ def xposition(index)
670
+ @menu.xposition(index)
671
+ end
672
+ def yposition(index)
673
+ @menu.yposition(index)
674
+ end
675
+ def menu
676
+ @menu
677
+ end
678
+ def menucget(key)
679
+ @menu.cget(key)
680
+ end
681
+ def menucget_strict(key)
682
+ @menu.cget_strict(key)
683
+ end
684
+ def menuconfigure(key, val=None)
685
+ @menu.configure(key, val)
686
+ self
687
+ end
688
+ def menuconfiginfo(key=nil)
689
+ @menu.configinfo(key)
690
+ end
691
+ def current_menuconfiginfo(key=nil)
692
+ @menu.current_configinfo(key)
693
+ end
694
+ def entrycget(index, key)
695
+ @menu.entrycget(index, key)
696
+ end
697
+ def entrycget_strict(index, key)
698
+ @menu.entrycget_strict(index, key)
699
+ end
700
+ def entryconfigure(index, key, val=None)
701
+ @menu.entryconfigure(index, key, val)
702
+ self
703
+ end
704
+ def entryconfiginfo(index, key=nil)
705
+ @menu.entryconfiginfo(index, key)
706
+ end
707
+ def current_entryconfiginfo(index, key=nil)
708
+ @menu.current_entryconfiginfo(index, key)
709
+ end
710
+ end
711
+
712
+ Tk::OptionMenuButton = Tk::OptionMenubutton
713
+ #TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton
714
+ #TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton
715
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton,
716
+ # :TkOptionMenubutton, :TkOptionMenuButton)
717
+ Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::OptionMenubutton,
718
+ :TkOptionMenubutton, :TkOptionMenuButton)