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,29 @@
1
+ #
2
+ # tkbgerror -- bgerror ( tkerror ) module
3
+ # 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
4
+ #
5
+ require 'tk'
6
+
7
+ module TkBgError
8
+ extend Tk
9
+
10
+ TkCommandNames = ['bgerror'.freeze].freeze
11
+
12
+ def bgerror(message)
13
+ tk_call('bgerror', message)
14
+ end
15
+ alias tkerror bgerror
16
+ alias show bgerror
17
+ module_function :bgerror, :tkerror, :show
18
+
19
+ def set_handler(hdlr = Proc.new) #==> handler :: proc{|msg| ...body... }
20
+ tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr) + ' $msg')
21
+ end
22
+ def set_default
23
+ begin
24
+ tk_call('rename', 'bgerror', '')
25
+ rescue RuntimeError
26
+ end
27
+ end
28
+ module_function :set_handler, :set_default
29
+ end
@@ -0,0 +1,138 @@
1
+ #
2
+ # tk/bind.rb : control event binding
3
+ #
4
+ require 'tk'
5
+
6
+ class TkBindTag
7
+ include TkBindCore
8
+
9
+ #BTagID_TBL = {}
10
+ BTagID_TBL = TkCore::INTERP.create_table
11
+
12
+ (Tk_BINDTAG_ID = ["btag".freeze, TkUtil.untrust("00000")]).instance_eval{
13
+ @mutex = Mutex.new
14
+ def mutex; @mutex; end
15
+ freeze
16
+ }
17
+
18
+ TkCore::INTERP.init_ip_env{
19
+ BTagID_TBL.mutex.synchronize{ BTagID_TBL.clear }
20
+ }
21
+
22
+ def TkBindTag.id2obj(id)
23
+ BTagID_TBL.mutex.synchronize{
24
+ (BTagID_TBL[id])? BTagID_TBL[id]: id
25
+ }
26
+ end
27
+
28
+ =begin
29
+ def TkBindTag.new_by_name(name, *args, &b)
30
+ BTagID_TBL.mutex.synchronize{
31
+ return BTagID_TBL[name] if BTagID_TBL[name]
32
+ }
33
+
34
+ self.new.instance_eval{
35
+ BTagID_TBL.mutex.synchronize{
36
+ BTagID_TBL.delete @id
37
+ @id = name
38
+ BTagID_TBL[@id] = self
39
+ }
40
+ bind(*args, &b) if args != []
41
+ self
42
+ }
43
+ end
44
+ =end
45
+ def TkBindTag.new_by_name(name, *args, &b)
46
+ obj = nil
47
+ BTagID_TBL.mutex.synchronize{
48
+ if BTagID_TBL[name]
49
+ obj = BTagID_TBL[name]
50
+ else
51
+ (obj = BTagID_TBL[name] = self.allocate).instance_eval{
52
+ @id = name
53
+ }
54
+ end
55
+ }
56
+ bind(*args, &b) if obj && args != []
57
+ obj
58
+ end
59
+
60
+ def initialize(*args, &b)
61
+ Tk_BINDTAG_ID.mutex.synchronize{
62
+ # @id = Tk_BINDTAG_ID.join('')
63
+ @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
64
+ Tk_BINDTAG_ID[1].succ!
65
+ }
66
+ BTagID_TBL.mutex.synchronize{
67
+ BTagID_TBL[@id] = self
68
+ }
69
+ bind(*args, &b) if args != []
70
+ end
71
+
72
+ ALL = self.new_by_name('all')
73
+
74
+ def name
75
+ @id
76
+ end
77
+
78
+ def to_eval
79
+ @id
80
+ end
81
+
82
+ def inspect
83
+ #Kernel.format "#<TkBindTag: %s>", @id
84
+ '#<TkBindTag: ' + @id + '>'
85
+ end
86
+ end
87
+
88
+
89
+ class TkBindTagAll<TkBindTag
90
+ def TkBindTagAll.new(*args, &b)
91
+ $stderr.puts "Warning: TkBindTagALL is obsolete. Use TkBindTag::ALL\n"
92
+
93
+ TkBindTag::ALL.bind(*args, &b) if args != []
94
+ TkBindTag::ALL
95
+ end
96
+ end
97
+
98
+
99
+ class TkDatabaseClass<TkBindTag
100
+ =begin
101
+ def self.new(name, *args, &b)
102
+ BTagID_TBL.mutex.synchronize{
103
+ return BTagID_TBL[name] if BTagID_TBL[name]
104
+ }
105
+ super(name, *args, &b)
106
+ end
107
+
108
+ def initialize(name, *args, &b)
109
+ @id = name
110
+ BTagID_TBL.mutex.synchronize{
111
+ BTagID_TBL[@id] = self
112
+ }
113
+ bind(*args, &b) if args != []
114
+ end
115
+ =end
116
+ def self.new(name, *args, &b)
117
+ BTagID_TBL.mutex.synchronize{
118
+ if BTagID_TBL[name]
119
+ BTagID_TBL[name]
120
+ else
121
+ BTagID_TBL[name] = self.allocate.instance_eval{
122
+ initialize(name, *args, &b)
123
+ self
124
+ }
125
+ end
126
+ }
127
+ end
128
+
129
+ def initialize(name, *args, &b)
130
+ @id = name
131
+ bind(*args, &b) if args != []
132
+ end
133
+
134
+ def inspect
135
+ #Kernel.format "#<TkDatabaseClass: %s>", @id
136
+ '#<TkDatabaseClass: ' + @id + '>'
137
+ end
138
+ end
@@ -0,0 +1,31 @@
1
+ #
2
+ # tk/button.rb : treat button widget
3
+ #
4
+ require 'tk'
5
+ require 'tk/label'
6
+
7
+ class Tk::Button<Tk::Label
8
+ TkCommandNames = ['button'.freeze].freeze
9
+ WidgetClassName = 'Button'.freeze
10
+ WidgetClassNames[WidgetClassName] ||= self
11
+ #def create_self(keys)
12
+ # if keys and keys != None
13
+ # tk_call_without_enc('button', @path, *hash_kv(keys, true))
14
+ # else
15
+ # tk_call_without_enc('button', @path)
16
+ # end
17
+ #end
18
+ #private :create_self
19
+
20
+ def invoke
21
+ _fromUTF8(tk_send_without_enc('invoke'))
22
+ end
23
+ def flash
24
+ tk_send_without_enc('flash')
25
+ self
26
+ end
27
+ end
28
+
29
+ #TkButton = Tk::Button unless Object.const_defined? :TkButton
30
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::Button, :TkButton)
31
+ Tk.__set_loaded_toplevel_aliases__('tk/button.rb', :Tk, Tk::Button, :TkButton)
@@ -0,0 +1,816 @@
1
+ #
2
+ # tk/canvas.rb - Tk canvas classes
3
+ # by Yukihiro Matsumoto <matz@caelum.co.jp>
4
+ #
5
+ require 'tk'
6
+ require 'tk/canvastag'
7
+ require 'tk/itemconfig'
8
+ require 'tk/scrollable'
9
+
10
+ module TkCanvasItemConfig
11
+ include TkItemConfigMethod
12
+
13
+ def __item_strval_optkeys(id)
14
+ # maybe need to override
15
+ super(id) + [
16
+ 'fill', 'activefill', 'disabledfill',
17
+ 'outline', 'activeoutline', 'disabledoutline'
18
+ ]
19
+ end
20
+ private :__item_strval_optkeys
21
+
22
+ def __item_methodcall_optkeys(id)
23
+ {'coords'=>'coords'}
24
+ end
25
+ private :__item_methodcall_optkeys
26
+
27
+ def __item_val2ruby_optkeys(id) # { key=>proc, ... }
28
+ super(id).update('window'=>proc{|i, v| window(v)},
29
+ 'tags'=>proc{|i, v|
30
+ simplelist(v).collect{|tag| TkcTag.id2obj(self, tag)}
31
+ })
32
+ end
33
+ private :__item_val2ruby_optkeys
34
+
35
+ def __item_pathname(tagOrId)
36
+ if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag)
37
+ self.path + ';' + tagOrId.id.to_s
38
+ else
39
+ self.path + ';' + tagOrId.to_s
40
+ end
41
+ end
42
+ private :__item_pathname
43
+ end
44
+
45
+ class Tk::Canvas<TkWindow
46
+ include TkCanvasItemConfig
47
+ include Tk::Scrollable
48
+
49
+ TkCommandNames = ['canvas'.freeze].freeze
50
+ WidgetClassName = 'Canvas'.freeze
51
+ WidgetClassNames[WidgetClassName] ||= self
52
+
53
+ def __destroy_hook__
54
+ TkcItem::CItemID_TBL.delete(@path)
55
+ end
56
+
57
+ #def create_self(keys)
58
+ # if keys and keys != None
59
+ # tk_call_without_enc('canvas', @path, *hash_kv(keys, true))
60
+ # else
61
+ # tk_call_without_enc('canvas', @path)
62
+ # end
63
+ #end
64
+ #private :create_self
65
+
66
+ def __numval_optkeys
67
+ super() + ['closeenough']
68
+ end
69
+ private :__numval_optkeys
70
+
71
+ def __boolval_optkeys
72
+ super() + ['confine']
73
+ end
74
+ private :__boolval_optkeys
75
+
76
+ def tagid(tag)
77
+ if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
78
+ tag.id
79
+ else
80
+ tag # maybe an Array of configure paramters
81
+ end
82
+ end
83
+ private :tagid
84
+
85
+
86
+ # create a canvas item without creating a TkcItem object
87
+ def create(type, *args)
88
+ type.create(self, *args)
89
+ end
90
+
91
+
92
+ def addtag(tag, mode, *args)
93
+ mode = mode.to_s
94
+ if args[0] && mode =~ /^(above|below|with(tag)?)$/
95
+ args[0] = tagid(args[0])
96
+ end
97
+ tk_send_without_enc('addtag', tagid(tag), mode, *args)
98
+ self
99
+ end
100
+ def addtag_above(tagOrId, target)
101
+ addtag(tagOrId, 'above', tagid(target))
102
+ end
103
+ def addtag_all(tagOrId)
104
+ addtag(tagOrId, 'all')
105
+ end
106
+ def addtag_below(tagOrId, target)
107
+ addtag(tagOrId, 'below', tagid(target))
108
+ end
109
+ def addtag_closest(tagOrId, x, y, halo=None, start=None)
110
+ addtag(tagOrId, 'closest', x, y, halo, start)
111
+ end
112
+ def addtag_enclosed(tagOrId, x1, y1, x2, y2)
113
+ addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
114
+ end
115
+ def addtag_overlapping(tagOrId, x1, y1, x2, y2)
116
+ addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
117
+ end
118
+ def addtag_withtag(tagOrId, tag)
119
+ addtag(tagOrId, 'withtag', tagid(tag))
120
+ end
121
+
122
+ def bbox(tagOrId, *tags)
123
+ list(tk_send_without_enc('bbox', tagid(tagOrId),
124
+ *tags.collect{|t| tagid(t)}))
125
+ end
126
+
127
+ #def itembind(tag, context, cmd=Proc.new, *args)
128
+ # _bind([path, "bind", tagid(tag)], context, cmd, *args)
129
+ # self
130
+ #end
131
+ def itembind(tag, context, *args)
132
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
133
+ if TkComm._callback_entry?(args[0]) || !block_given?
134
+ cmd = args.shift
135
+ else
136
+ cmd = Proc.new
137
+ end
138
+ _bind([path, "bind", tagid(tag)], context, cmd, *args)
139
+ self
140
+ end
141
+
142
+ #def itembind_append(tag, context, cmd=Proc.new, *args)
143
+ # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
144
+ # self
145
+ #end
146
+ def itembind_append(tag, context, *args)
147
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
148
+ if TkComm._callback_entry?(args[0]) || !block_given?
149
+ cmd = args.shift
150
+ else
151
+ cmd = Proc.new
152
+ end
153
+ _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
154
+ self
155
+ end
156
+
157
+ def itembind_remove(tag, context)
158
+ _bind_remove([path, "bind", tagid(tag)], context)
159
+ self
160
+ end
161
+
162
+ def itembindinfo(tag, context=nil)
163
+ _bindinfo([path, "bind", tagid(tag)], context)
164
+ end
165
+
166
+ def canvasx(screen_x, *args)
167
+ #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
168
+ number(tk_send_without_enc('canvasx', screen_x, *args))
169
+ end
170
+ def canvasy(screen_y, *args)
171
+ #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
172
+ number(tk_send_without_enc('canvasy', screen_y, *args))
173
+ end
174
+ alias canvas_x canvasx
175
+ alias canvas_y canvasy
176
+
177
+ def coords(tag, *args)
178
+ if args.empty?
179
+ tk_split_list(tk_send_without_enc('coords', tagid(tag)))
180
+ else
181
+ tk_send_without_enc('coords', tagid(tag), *(args.flatten))
182
+ self
183
+ end
184
+ end
185
+
186
+ def dchars(tag, first, last=None)
187
+ tk_send_without_enc('dchars', tagid(tag),
188
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
189
+ self
190
+ end
191
+
192
+ def delete(*args)
193
+ tbl = nil
194
+ TkcItem::CItemID_TBL.mutex.synchronize{
195
+ tbl = TkcItem::CItemID_TBL[self.path]
196
+ }
197
+ if tbl
198
+ args.each{|tag|
199
+ find('withtag', tag).each{|item|
200
+ if item.kind_of?(TkcItem)
201
+ TkcItem::CItemID_TBL.mutex.synchronize{
202
+ tbl.delete(item.id)
203
+ }
204
+ end
205
+ }
206
+ }
207
+ end
208
+ tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
209
+ self
210
+ end
211
+ alias remove delete
212
+
213
+ def dtag(tag, tag_to_del=None)
214
+ tk_send_without_enc('dtag', tagid(tag), tagid(tag_to_del))
215
+ self
216
+ end
217
+ alias deltag dtag
218
+
219
+ def find(mode, *args)
220
+ list(tk_send_without_enc('find', mode, *args)).collect!{|id|
221
+ TkcItem.id2obj(self, id)
222
+ }
223
+ end
224
+ def find_above(target)
225
+ find('above', tagid(target))
226
+ end
227
+ def find_all
228
+ find('all')
229
+ end
230
+ def find_below(target)
231
+ find('below', tagid(target))
232
+ end
233
+ def find_closest(x, y, halo=None, start=None)
234
+ find('closest', x, y, halo, start)
235
+ end
236
+ def find_enclosed(x1, y1, x2, y2)
237
+ find('enclosed', x1, y1, x2, y2)
238
+ end
239
+ def find_overlapping(x1, y1, x2, y2)
240
+ find('overlapping', x1, y1, x2, y2)
241
+ end
242
+ def find_withtag(tag)
243
+ find('withtag', tag)
244
+ end
245
+
246
+ def itemfocus(tagOrId=nil)
247
+ if tagOrId
248
+ tk_send_without_enc('focus', tagid(tagOrId))
249
+ self
250
+ else
251
+ ret = tk_send_without_enc('focus')
252
+ if ret == ""
253
+ nil
254
+ else
255
+ TkcItem.id2obj(self, ret)
256
+ end
257
+ end
258
+ end
259
+
260
+ def gettags(tagOrId)
261
+ list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
262
+ TkcTag.id2obj(self, tag)
263
+ }
264
+ end
265
+
266
+ def icursor(tagOrId, index)
267
+ tk_send_without_enc('icursor', tagid(tagOrId), index)
268
+ self
269
+ end
270
+
271
+ def imove(tagOrId, idx, x, y)
272
+ tk_send_without_enc('imove', tagid(tagOrId), idx, x, y)
273
+ self
274
+ end
275
+ alias i_move imove
276
+
277
+ def index(tagOrId, idx)
278
+ number(tk_send_without_enc('index', tagid(tagOrId), idx))
279
+ end
280
+
281
+ def insert(tagOrId, index, string)
282
+ tk_send_without_enc('insert', tagid(tagOrId), index,
283
+ _get_eval_enc_str(string))
284
+ self
285
+ end
286
+
287
+ =begin
288
+ def itemcget(tagOrId, option)
289
+ case option.to_s
290
+ when 'dash', 'activedash', 'disableddash'
291
+ conf = tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}")
292
+ if conf =~ /^[0-9]/
293
+ list(conf)
294
+ else
295
+ conf
296
+ end
297
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
298
+ _fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}"))
299
+ when 'font', 'kanjifont'
300
+ #fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), "-#{option}"))
301
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_with_enc('itemcget', tagid(tagOrId), '-font')))
302
+ unless fnt.kind_of?(TkFont)
303
+ fnt = tagfontobj(tagid(tagOrId), fnt)
304
+ end
305
+ if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
306
+ # obsolete; just for compatibility
307
+ fnt.kanji_font
308
+ else
309
+ fnt
310
+ end
311
+ else
312
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
313
+ "-#{option}")))
314
+ end
315
+ end
316
+
317
+ def itemconfigure(tagOrId, key, value=None)
318
+ if key.kind_of? Hash
319
+ key = _symbolkey2str(key)
320
+ coords = key.delete('coords')
321
+ self.coords(tagOrId, coords) if coords
322
+
323
+ if ( key['font'] || key['kanjifont'] \
324
+ || key['latinfont'] || key['asciifont'] )
325
+ tagfont_configure(tagid(tagOrId), key.dup)
326
+ else
327
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
328
+ *hash_kv(key, true)))
329
+ end
330
+
331
+ else
332
+ if ( key == 'coords' || key == :coords )
333
+ self.coords(tagOrId, value)
334
+ elsif ( key == 'font' || key == :font ||
335
+ key == 'kanjifont' || key == :kanjifont ||
336
+ key == 'latinfont' || key == :latinfont ||
337
+ key == 'asciifont' || key == :asciifont )
338
+ if value == None
339
+ tagfontobj(tagid(tagOrId))
340
+ else
341
+ tagfont_configure(tagid(tagOrId), {key=>value})
342
+ end
343
+ else
344
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
345
+ "-#{key}", _get_eval_enc_str(value)))
346
+ end
347
+ end
348
+ self
349
+ end
350
+ # def itemconfigure(tagOrId, key, value=None)
351
+ # if key.kind_of? Hash
352
+ # tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key)
353
+ # else
354
+ # tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
355
+ # end
356
+ # end
357
+ # def itemconfigure(tagOrId, keys)
358
+ # tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(keys)
359
+ # end
360
+
361
+ def itemconfiginfo(tagOrId, key=nil)
362
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
363
+ if key
364
+ case key.to_s
365
+ when 'coords'
366
+ return ['coords', '', '', '', self.coords(tagOrId)]
367
+ when 'dash', 'activedash', 'disableddash'
368
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
369
+ if conf[3] && conf[3] =~ /^[0-9]/
370
+ conf[3] = list(conf[3])
371
+ end
372
+ if conf[4] && conf[4] =~ /^[0-9]/
373
+ conf[4] = list(conf[4])
374
+ end
375
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
376
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
377
+ when 'font', 'kanjifont'
378
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
379
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
380
+ else
381
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
382
+ end
383
+ conf[0] = conf[0][1..-1]
384
+ conf
385
+ else
386
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
387
+ conf = tk_split_simplelist(conflist)
388
+ conf[0] = conf[0][1..-1]
389
+ case conf[0]
390
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
391
+ when 'dash', 'activedash', 'disableddash'
392
+ if conf[3] && conf[3] =~ /^[0-9]/
393
+ conf[3] = list(conf[3])
394
+ end
395
+ if conf[4] && conf[4] =~ /^[0-9]/
396
+ conf[4] = list(conf[4])
397
+ end
398
+ else
399
+ if conf[3]
400
+ if conf[3].index('{')
401
+ conf[3] = tk_split_list(conf[3])
402
+ else
403
+ conf[3] = tk_tcl2ruby(conf[3])
404
+ end
405
+ end
406
+ if conf[4]
407
+ if conf[4].index('{')
408
+ conf[4] = tk_split_list(conf[4])
409
+ else
410
+ conf[4] = tk_tcl2ruby(conf[4])
411
+ end
412
+ end
413
+ end
414
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
415
+ conf
416
+ }
417
+
418
+ fontconf = ret.assoc('font')
419
+ if fontconf
420
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
421
+ fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
422
+ ret.push(fontconf)
423
+ end
424
+
425
+ ret << ['coords', '', '', '', self.coords(tagOrId)]
426
+ end
427
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
428
+ if key
429
+ case key.to_s
430
+ when 'coords'
431
+ {'coords' => ['', '', '', self.coords(tagOrId)]}
432
+ when 'dash', 'activedash', 'disableddash'
433
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
434
+ tagid(tagOrId),
435
+ "-#{key}"))
436
+ if conf[3] && conf[3] =~ /^[0-9]/
437
+ conf[3] = list(conf[3])
438
+ end
439
+ if conf[4] && conf[4] =~ /^[0-9]/
440
+ conf[4] = list(conf[4])
441
+ end
442
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
443
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
444
+ when 'font', 'kanjifont'
445
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
446
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
447
+ else
448
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
449
+ end
450
+ key = conf.shift[1..-1]
451
+ { key => conf }
452
+ else
453
+ ret = {}
454
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
455
+ conf = tk_split_simplelist(conflist)
456
+ key = conf.shift[1..-1]
457
+ case key
458
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
459
+ when 'dash', 'activedash', 'disableddash'
460
+ if conf[2] && conf[2] =~ /^[0-9]/
461
+ conf[2] = list(conf[2])
462
+ end
463
+ if conf[3] && conf[3] =~ /^[0-9]/
464
+ conf[3] = list(conf[3])
465
+ end
466
+ else
467
+ if conf[2]
468
+ if conf[2].index('{')
469
+ conf[2] = tk_split_list(conf[2])
470
+ else
471
+ conf[2] = tk_tcl2ruby(conf[2])
472
+ end
473
+ end
474
+ if conf[3]
475
+ if conf[3].index('{')
476
+ conf[3] = tk_split_list(conf[3])
477
+ else
478
+ conf[3] = tk_tcl2ruby(conf[3])
479
+ end
480
+ end
481
+ end
482
+ if conf.size == 1
483
+ ret[key] = conf[0][1..-1] # alias info
484
+ else
485
+ ret[key] = conf
486
+ end
487
+ }
488
+
489
+ fontconf = ret['font']
490
+ if fontconf
491
+ ret.delete('font')
492
+ ret.delete('kanjifont')
493
+ fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
494
+ ret['font'] = fontconf
495
+ end
496
+
497
+ ret['coords'] = ['', '', '', self.coords(tagOrId)]
498
+
499
+ ret
500
+ end
501
+ end
502
+ end
503
+
504
+ def current_itemconfiginfo(tagOrId, key=nil)
505
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
506
+ if key
507
+ conf = itemconfiginfo(tagOrId, key)
508
+ {conf[0] => conf[4]}
509
+ else
510
+ ret = {}
511
+ itemconfiginfo(tagOrId).each{|conf|
512
+ ret[conf[0]] = conf[4] if conf.size > 2
513
+ }
514
+ ret
515
+ end
516
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
517
+ ret = {}
518
+ itemconfiginfo(tagOrId, key).each{|k, conf|
519
+ ret[k] = conf[-1] if conf.kind_of?(Array)
520
+ }
521
+ ret
522
+ end
523
+ end
524
+ =end
525
+
526
+ def lower(tag, below=nil)
527
+ if below
528
+ tk_send_without_enc('lower', tagid(tag), tagid(below))
529
+ else
530
+ tk_send_without_enc('lower', tagid(tag))
531
+ end
532
+ self
533
+ end
534
+
535
+ def move(tag, dx, dy)
536
+ tk_send_without_enc('move', tagid(tag), dx, dy)
537
+ self
538
+ end
539
+
540
+ def moveto(tag, x, y)
541
+ # Tcl/Tk 8.6 or later
542
+ tk_send_without_enc('moveto', tagid(tag), x, y)
543
+ self
544
+ end
545
+ alias move_to moveto
546
+
547
+ def postscript(keys)
548
+ tk_send("postscript", *hash_kv(keys))
549
+ end
550
+
551
+ def raise(tag, above=nil)
552
+ if above
553
+ tk_send_without_enc('raise', tagid(tag), tagid(above))
554
+ else
555
+ tk_send_without_enc('raise', tagid(tag))
556
+ end
557
+ self
558
+ end
559
+
560
+ def rchars(tag, first, last, str_or_coords)
561
+ # Tcl/Tk 8.6 or later
562
+ str_or_coords = str_or_coords.flatten if str_or_coords.kinad_of? Array
563
+ tk_send_without_enc('rchars', tagid(tag), first, last, str_or_coords)
564
+ self
565
+ end
566
+ alias replace_chars rchars
567
+ alias replace_coords rchars
568
+
569
+ def scale(tag, x, y, xs, ys)
570
+ tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
571
+ self
572
+ end
573
+
574
+ def scan_mark(x, y)
575
+ tk_send_without_enc('scan', 'mark', x, y)
576
+ self
577
+ end
578
+ def scan_dragto(x, y, gain=None)
579
+ tk_send_without_enc('scan', 'dragto', x, y, gain)
580
+ self
581
+ end
582
+
583
+ def select(mode, *args)
584
+ r = tk_send_without_enc('select', mode, *args)
585
+ (mode == 'item')? TkcItem.id2obj(self, r): self
586
+ end
587
+ def select_adjust(tagOrId, index)
588
+ select('adjust', tagid(tagOrId), index)
589
+ end
590
+ def select_clear
591
+ select('clear')
592
+ end
593
+ def select_from(tagOrId, index)
594
+ select('from', tagid(tagOrId), index)
595
+ end
596
+ def select_item
597
+ select('item')
598
+ end
599
+ def select_to(tagOrId, index)
600
+ select('to', tagid(tagOrId), index)
601
+ end
602
+
603
+ def itemtype(tag)
604
+ TkcItem.type2class(tk_send('type', tagid(tag)))
605
+ end
606
+ end
607
+
608
+ #TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas
609
+ #Tk.__set_toplevel_aliases__(:Tk, Tk::Canvas, :TkCanvas)
610
+ Tk.__set_loaded_toplevel_aliases__('tk/canvas.rb', :Tk, Tk::Canvas, :TkCanvas)
611
+
612
+
613
+ class TkcItem<TkObject
614
+ extend Tk
615
+ include TkcTagAccess
616
+ extend TkItemFontOptkeys
617
+ extend TkItemConfigOptkeys
618
+
619
+ CItemTypeName = nil
620
+ CItemTypeToClass = {}
621
+
622
+ CItemID_TBL = TkCore::INTERP.create_table
623
+
624
+ TkCore::INTERP.init_ip_env{
625
+ CItemID_TBL.mutex.synchronize{ CItemID_TBL.clear }
626
+ }
627
+
628
+ def TkcItem.type2class(type)
629
+ CItemTypeToClass[type]
630
+ end
631
+
632
+ def TkcItem.id2obj(canvas, id)
633
+ cpath = canvas.path
634
+ CItemID_TBL.mutex.synchronize{
635
+ if CItemID_TBL[cpath]
636
+ CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
637
+ else
638
+ id
639
+ end
640
+ }
641
+ end
642
+
643
+ ########################################
644
+ def self._parse_create_args(args)
645
+ fontkeys = {}
646
+ methodkeys = {}
647
+ if args[-1].kind_of? Hash
648
+ keys = _symbolkey2str(args.pop)
649
+ if args.size == 0
650
+ args = keys.delete('coords')
651
+ unless args.kind_of?(Array)
652
+ fail "coords parameter must be given by an Array"
653
+ end
654
+ end
655
+
656
+ #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
657
+ # fontkeys[key] = keys.delete(key) if keys.key?(key)
658
+ #}
659
+ __item_font_optkeys(nil).each{|key|
660
+ fkey = key.to_s
661
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
662
+
663
+ fkey = "kanji#{key}"
664
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
665
+
666
+ fkey = "latin#{key}"
667
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
668
+
669
+ fkey = "ascii#{key}"
670
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
671
+ }
672
+
673
+ __item_optkey_aliases(nil).each{|alias_name, real_name|
674
+ alias_name = alias_name.to_s
675
+ if keys.has_key?(alias_name)
676
+ keys[real_name.to_s] = keys.delete(alias_name)
677
+ end
678
+ }
679
+
680
+ __item_methodcall_optkeys(nil).each{|key|
681
+ key = key.to_s
682
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
683
+ }
684
+
685
+ __item_ruby2val_optkeys(nil).each{|key, method|
686
+ key = key.to_s
687
+ keys[key] = method.call(keys[key]) if keys.has_key?(key)
688
+ }
689
+
690
+ #args = args.flatten.concat(hash_kv(keys))
691
+ args = args.flatten.concat(itemconfig_hash_kv(nil, keys))
692
+ else
693
+ args = args.flatten
694
+ end
695
+
696
+ [args, fontkeys, methodkeys]
697
+ end
698
+ private_class_method :_parse_create_args
699
+
700
+ def self.create(canvas, *args)
701
+ unless self::CItemTypeName
702
+ fail RuntimeError, "#{self} is an abstract class"
703
+ end
704
+ args, fontkeys, methodkeys = _parse_create_args(args)
705
+ idnum = tk_call_without_enc(canvas.path, 'create',
706
+ self::CItemTypeName, *args)
707
+ canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
708
+ canvas.itemconfigure(idnum, methodkeys) unless methodkeys.empty?
709
+ idnum.to_i # 'canvas item id' is an integer number
710
+ end
711
+ ########################################
712
+
713
+ def initialize(parent, *args)
714
+ #unless parent.kind_of?(Tk::Canvas)
715
+ # fail ArgumentError, "expect Tk::Canvas for 1st argument"
716
+ #end
717
+ @parent = @c = parent
718
+ @path = parent.path
719
+
720
+ @id = create_self(*args) # an integer number as 'canvas item id'
721
+ CItemID_TBL.mutex.synchronize{
722
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
723
+ CItemID_TBL[@path][@id] = self
724
+ }
725
+ end
726
+ def create_self(*args)
727
+ self.class.create(@c, *args) # return an integer number as 'canvas item id'
728
+ end
729
+ private :create_self
730
+
731
+ def id
732
+ @id
733
+ end
734
+
735
+ def exist?
736
+ if @c.find_withtag(@id)
737
+ true
738
+ else
739
+ false
740
+ end
741
+ end
742
+
743
+ def delete
744
+ @c.delete @id
745
+ CItemID_TBL.mutex.synchronize{
746
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
747
+ }
748
+ self
749
+ end
750
+ alias remove delete
751
+ alias destroy delete
752
+ end
753
+
754
+ class TkcArc<TkcItem
755
+ CItemTypeName = 'arc'.freeze
756
+ CItemTypeToClass[CItemTypeName] = self
757
+ end
758
+
759
+ class TkcBitmap<TkcItem
760
+ CItemTypeName = 'bitmap'.freeze
761
+ CItemTypeToClass[CItemTypeName] = self
762
+ end
763
+
764
+ class TkcImage<TkcItem
765
+ CItemTypeName = 'image'.freeze
766
+ CItemTypeToClass[CItemTypeName] = self
767
+ end
768
+
769
+ class TkcLine<TkcItem
770
+ CItemTypeName = 'line'.freeze
771
+ CItemTypeToClass[CItemTypeName] = self
772
+ end
773
+
774
+ class TkcOval<TkcItem
775
+ CItemTypeName = 'oval'.freeze
776
+ CItemTypeToClass[CItemTypeName] = self
777
+ end
778
+
779
+ class TkcPolygon<TkcItem
780
+ CItemTypeName = 'polygon'.freeze
781
+ CItemTypeToClass[CItemTypeName] = self
782
+ end
783
+
784
+ class TkcRectangle<TkcItem
785
+ CItemTypeName = 'rectangle'.freeze
786
+ CItemTypeToClass[CItemTypeName] = self
787
+ end
788
+
789
+ class TkcText<TkcItem
790
+ CItemTypeName = 'text'.freeze
791
+ CItemTypeToClass[CItemTypeName] = self
792
+ def self.create(canvas, *args)
793
+ if args[-1].kind_of?(Hash)
794
+ keys = _symbolkey2str(args.pop)
795
+ txt = keys['text']
796
+ keys['text'] = _get_eval_enc_str(txt) if txt
797
+ args.push(keys)
798
+ end
799
+ super(canvas, *args)
800
+ end
801
+ end
802
+
803
+ class TkcWindow<TkcItem
804
+ CItemTypeName = 'window'.freeze
805
+ CItemTypeToClass[CItemTypeName] = self
806
+ def self.create(canvas, *args)
807
+ if args[-1].kind_of?(Hash)
808
+ keys = _symbolkey2str(args.pop)
809
+ win = keys['window']
810
+ # keys['window'] = win.epath if win.kind_of?(TkWindow)
811
+ keys['window'] = _epath(win) if win
812
+ args.push(keys)
813
+ end
814
+ super(canvas, *args)
815
+ end
816
+ end