summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/lib/tkextlib
diff options
context:
space:
mode:
Diffstat (limited to 'jni/ruby/ext/tk/lib/tkextlib')
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/ICONS.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb129
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS193
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt.rb189
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb79
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb83
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/component.rb2218
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/container.rb28
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb23
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb269
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb32
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb67
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb23
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb74
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/table.rb412
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb110
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb504
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb25
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb17
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb17
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb1058
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb1287
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb141
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb256
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb107
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget.rb153
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb31
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb90
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb194
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb31
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb39
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb63
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb43
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb41
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb80
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb52
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb361
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb132
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb192
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb166
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb42
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb67
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb44
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb40
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb25
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb91
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb98
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb500
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb129
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itcl.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb178
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itk.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb446
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb94
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb121
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb125
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb53
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb130
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb104
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb121
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb50
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb185
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb40
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb46
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb35
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb46
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb42
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb365
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb50
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb39
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb45
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb67
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb212
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb93
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb92
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb134
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb131
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb35
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb121
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb24
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb353
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb59
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb207
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb568
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb102
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb92
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb30
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb169
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb181
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb145
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb25
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb56
-rwxr-xr-xjni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb184
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib.rb105
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/README135
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb158
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb55
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb36
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb151
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb117
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb160
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb97
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb224
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb84
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb134
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb146
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb75
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb47
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb146
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb78
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb1404
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb65
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb79
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb51
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb150
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb28
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb1072
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb43
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb314
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb104
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb65
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb82
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tclx.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb74
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile.rb449
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb102
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb32
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/style.rb336
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb55
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb49
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb147
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb245
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb1336
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb56
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb63
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb107
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb30
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND.rb18
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb125
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb182
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb453
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg.rb36
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/README26
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb44
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktable.rb14
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb966
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktrans.rb14
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb64
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/treectrl.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb2522
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/trofs.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb51
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/version.rb6
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb53
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb102
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb286
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb22
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/winico.rb14
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb224
253 files changed, 32997 insertions, 0 deletions
diff --git a/jni/ruby/ext/tk/lib/tkextlib/ICONS.rb b/jni/ruby/ext/tk/lib/tkextlib/ICONS.rb
new file mode 100644
index 0000000..18d84c0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/ICONS.rb
@@ -0,0 +1,13 @@
+#
+# ICONS support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/ICONS/setup.rb'
+
+# load library
+require 'tkextlib/ICONS/icons'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb b/jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb
new file mode 100644
index 0000000..bd3180a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb
@@ -0,0 +1,129 @@
+#
+# tkextlib/ICONS/icons.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/ICONS/setup.rb'
+
+# TkPackage.require('icons', '1.0')
+TkPackage.require('icons')
+
+module Tk
+ class ICONS < TkImage
+ extend Tk
+
+ PACKAGE_NAME = 'icons'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('icons')
+ rescue
+ ''
+ end
+ end
+
+ def self.create(*args) # icon, icon, ..., ?option=>value, ...?
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ icons = simplelist(tk_call('::icons::icons', 'create',
+ *(hash_kv(keys) << (args.flatten))))
+ else
+ icons = simplelist(tk_call('::icons::icons', 'create',
+ args.flatten))
+ end
+
+ icons.collect{|icon| self.new(icon, :without_creating=>true)}
+ end
+
+ def self.delete(*icons) # icon, icon, ...
+ icons = icons.flatten
+ return if icons.empty?
+ icons.map!{|icon|
+ if icon.kind_of?(Tk::ICONS)
+ Tk_IMGTBL.delete(icon.path)
+ icon.name
+ elsif icon.to_s =~ /^::icon::(.*)/
+ name = $1
+ Tk_IMGTBL.delete(icon)
+ name
+ else
+ Tk_IMGTBL.delete("::icon::#{icon}")
+ icon
+ end
+ }
+ tk_call('::icons::icons', 'delete', icons)
+ end
+
+ def self.query(*args) # icon, icon, ..., ?option=>value, ...?
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ simplelist(tk_call('::icons::icons', 'query',
+ *(hash_kv(keys) << (args.flatten))))
+ else
+ simplelist(tk_call('::icons::icons', 'query', args.flatten))
+ end . map{|inf| list(inf) }
+ end
+
+ ##########################################
+
+ class << self
+ alias _new new
+
+ def new(name, keys=nil)
+ if obj = Tk_IMGTBL["::icon::#{name}"]
+ if keys
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ tk_call('::icons::icons', 'create', *(hash_kv(keys) << obj.name))
+ end
+ end
+ else
+ obj = _new(name, keys)
+ end
+ obj
+ end
+ end
+
+ ##########################################
+
+ def initialize(name, keys=nil)
+ if name.kind_of?(String) && name =~ /^::icon::(.+)$/
+ @name = $1
+ @path = name
+ else
+ @name = name.to_s
+ @path = "::icon::#{@name}"
+ end
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name))
+ end
+ Tk_IMGTBL[@path] = self
+ end
+
+ def name
+ @name
+ end
+
+ def delete
+ Tk_IMGTBL.delete(@path)
+ tk_call('::icons::icons', 'delete', @name)
+ self
+ end
+
+ def query(keys={})
+ list(simplelist(tk_call('::icons::icons', 'query',
+ *(hash_kv(keys) << @name))
+ )[0])
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS b/jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS
new file mode 100644
index 0000000..de51c51
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -0,0 +1,193 @@
+
+ [ current support status of Tcl/Tk extensions ]
+
+ *** RELEASE_DATE of the libraries => see 'tkextlib/version.rb' ***
+
+The following list shows *CURRENT* status when this file was modified
+at last. If you want to add other Tcl/Tk extensions to the planed list
+(or change its status position), please request them at the ruby-talk,
+ruby-list, or ruby-dev ML. Although we cannot promise to support your
+requests, we'll try to do.
+
+If you want to check that wrapper libraries are ready to use on your
+environment, please execute 'pkg_checker.rb' with no arguments. The
+script may give you some hints about that.
+
+
+ ***** IMPORTANT NOTE **********************************************
+
+ 'support' means that Ruby/Tk's wrapper libraries are released.
+ 'not support' does *NOT* mean that the extension doesn't work
+ on Ruby/Tk.
+
+ The version number of each extension means the latest version
+ which is checked its feature. That is, it does NOT means only
+ version of working. Library files maybe include some features
+ which is included in the former version but removed from the
+ latest, and maybe able to support the later version then the
+ shown version.
+
+ Even if the status of the extension is 'not support', you can
+ control the functions/widgets of the extension without wrapper
+ libraries by Tk.tk_call(), Tk.ip_eval(), and so on.
+
+ If you cannot use installed Tcl/Tk extension, please check the
+ followings.
+
+ (1) On your Tcl/Tk, does the extension work?
+
+ (2) Do DLL libraries of the extension exist on DLL load-path?
+ (See also "<ruby archive>/ext/tcltklib/README.ActiveTcl")
+
+ (3) Is the Tcl library directory of the extension included in
+ library search-path of the Tcl interpreter linked Ruby/Tk?
+
+ The check results may request you to do some setup operations
+ before using the extension. If so, then please write the step
+ of setup operations into the "setup.rb" file in the directory
+ of the wrapper libraries for the extension (It is the wrapper
+ libraries have the standard structure of the libraries in this
+ directory). The "setup" file is required before requiring the
+ Tcl library package (TkPackage.require(<libname>)).
+
+ *******************************************************************
+
+
+===< support with some examples (may be beta quality) >=======================
+
+Tcllib 1.11.1
+Tklib 0.5 http://sourceforge.net/projects/tcllib ==> tcllib
+ ( partial support; primary support target is Tklib)
+
+IWidgets 4.0.2 http://sourceforge.net/projects/incrtcl ==> iwidgets
+
+BWidget 1.8 [ CVS/Hd(2009-07-02) ]
+ http://sourceforge.net/projects/tcllib ==> bwidget
+
+TkTable 2.10 http://sourceforge.net/projects/tktable ==> tktable
+ * see also <http://www.korus.hu/~fery/ruby/tktable.rb>
+ written by Ferenc Engard (ferenc@engard.hu)
+
+Vu widgets 2.3.0 http://sourceforge.net/projects/tktable ==> vu
+
+TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/ ==> tkHTML
+
+ICONS 1.0 http://www.satisoft.com/tcltk/icons/ ==> ICONS
+
+TkImg 1.3 http://sourceforge.net/projects/tkimg ==> tkimg
+
+
+BLT 2.4z http://sourceforge.net/projects/blt ==> blt
+
+TkTreeCtrl 2.2.9
+ http://tktreectrl.sourceforge.net/ ==> treectrl
+
+Tile 0.8.3/8.6b1
+ http://sourceforge.net/projects/tktable ==> tile
+
+
+
+===< support (may be alpha or beta quality) >=================================
+
+IncrTcl CVS/Hd(2008-12-15)
+ http://sourceforge.net/projects/incrtcl ==> itcl, itk
+
+TclX CVS/Hd(2008-12-15)
+ http://sourceforge.net/projects/tclx
+ ==> tclx (partial support; infox command and
+ XPG/3 message catalogs only)
+
+Trofs 0.4.4 http://math.nist.gov/~DPorter/tcltk/trofs/
+
+
+
+===< possibly available (not tested; alpha quality) >=========================
+
+winico 0.6
+ http://sourceforge.net/projects/tktable
+ ==> winico (win32 only)
+
+TkTrans latest(2004-10-11)
+ http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html
+ ==> tktrans (win32 only)
+
+TkDND 1.0a2 http://sourceforge.net/projects/tkdnd ==> tkDND
+
+
+
+===< plan to support (alpha quality libraries may be included) >==============
+
+GraphViz *** http://www.graphviz.org/
+
+Tkgeomap *** http://tkgeomap.sourceforge.net/index.html
+
+
+
+===< not determined to supprt or not >========================================
+
+Tix *** http://tixlibrary.sourceforge.net/
+
+TkZinc *** http://www.tkzinc.org/
+
+Wbc *** http://home.t-online.de/home/csaba.nemethi/
+
+Mentry *** http://home.t-online.de/home/csaba.nemethi/
+
+Tablelist *** http://home.t-online.de/home/csaba.nemethi/
+
+ANIGIF *** http://cardtable.sourceforge.net/tcltk/
+
+IMG_ROTATE *** http://cardtable.sourceforge.net/tcltk/
+
+TclVfs *** http://sourceforge.net/projects/tclvfs/
+
+vfwtcl *** http://sourceforge.net/projects/avicaptcl
+ * Win32 only
+
+multicast *** http://sourceforge.net/projects/avicaptcl
+ * Win32 only
+
+XBit *** http://www.geocities.com/~chengye/
+ * current implementation is for Windows only
+
+QuickTimeTcl *** http://hem.fyristorg.com/matben/qt/
+ * works under Mac OS (8,9,X) or Windows
+
+
+
+===< may not support (already exist, out of Ruby/Tk scope, and so on) >=======
+
+TkCon *** http://sourceforge.net/projects/tkcon
+
+Expect *** http://sourceforge.net/projects/expect
+
+TclXML *** http://sourceforge.net/projects/tclxml
+
+TclXSLT *** http://sourceforge.net/projects/tclxml
+
+TclDOM *** http://sourceforge.net/projects/tclxml
+
+TclSOAP *** http://sourceforge.net/projects/tclsoap
+
+Snack *** http://www.speech.kth.se/~kare/snack2.2.tar.gz
+ * use Snack for Ruby
+ (see http://rbsnack.sourceforge.net/)
+
+Tcom *** http://www.vex.net/~cthuang/tcom/
+
+tDOM *** http://www.tdom.org
+
+Mk4tcl *** http://www.equi4.com/metakit/tcl.html
+
+Memchan *** http://sourceforge.net/projects/memchan
+
+XOTcl *** http://www.xotcl.org/
+
+
+===< tool (may not supprt) >==================================================
+
+tbcload/tclcompiler
+ *** http://www.tcl.tk/software/tclpro/
+
+
+(End of List)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt.rb b/jni/ruby/ext/tk/lib/tkextlib/blt.rb
new file mode 100644
index 0000000..8b132e4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt.rb
@@ -0,0 +1,189 @@
+#
+# BLT support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/variable'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/blt/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('BLT', '2.4')
+TkPackage.require('BLT')
+
+module Tk
+ module BLT
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+ # Require autoload-symbols which is a same name as widget classname.
+ # Those are used at TkComm._genobj_for_tkwidget method.
+
+ extend TkCore
+
+ VERSION = tk_call('set', 'blt_version')
+ PATCH_LEVEL = tk_call('set', 'blt_patchLevel')
+
+ begin
+ lib = TkCore::INTERP._invoke('set', 'blt_library')
+ rescue
+ lib = ''
+ end
+ LIBRARY = TkVarAccess.new('blt_library', lib)
+
+ begin
+ lib = TkCore::INTERP._invoke('set', 'blt_libPath')
+ rescue
+ lib = ''
+ end
+ LIB_PATH = TkVarAccess.new('blt_libPath', lib)
+
+ PACKAGE_NAME = 'BLT'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('BLT')
+ rescue
+ ''
+ end
+ end
+
+ ####################################################
+
+ def self.beep(percent = 50)
+ tk_call('::blt::beep', percent)
+ end
+
+ def self.bgexec(*args)
+ if args[0].kind_of?(TkVariable)
+ var = args.shift
+ else
+ var = TkVariable.new
+ end
+ params = [var]
+
+ params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
+
+ params << '--' if args[0] =~ /^\s*-[^-]/
+ params.concat(args)
+
+ tk_call('::blt::bgexec', *params)
+ var
+ end
+
+ def self.detach_bgexec(*args)
+ if args[0].kind_of?(TkVariable)
+ var = args.shift
+ else
+ var = TkVariable.new
+ end
+ params = [var]
+
+ params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
+
+ params << '--' if args[0] =~ /^\s*-[^-]/
+ params.concat(args)
+ params << '&'
+
+ [var, tk_split_list(tk_call('::blt::bgexec', *params))]
+ end
+
+ def self.bltdebug(lvl = nil)
+ if lvl
+ tk_call('::blt::bltdebug', lvl)
+ else
+ number(tk_call('::blt::bltdebug'))
+ end
+ end
+
+ def self.crc32_file(name)
+ tk_call_without_enc('::blt::crc32', name)
+ end
+ def self.crc32_data(dat)
+ tk_call_without_enc('::blt::crc32', '-data', dat)
+ end
+
+ ####################################################
+
+ def self.active_legend(graph)
+ tk_call_without_enc('Blt_ActiveLegend', graph)
+ end
+ def self.crosshairs(graph)
+ tk_call_without_enc('Blt_Crosshairs', graph)
+ end
+ def self.zoom_stack(graph)
+ tk_call_without_enc('Blt_ZoomStack', graph)
+ end
+ def self.print_key(graph)
+ tk_call_without_enc('Blt_PrintKey', graph)
+ end
+ def self.closest_point(graph)
+ tk_call_without_enc('Blt_ClosestPoint', graph)
+ end
+
+ module GraphCommand
+ def active_legend
+ tk_call_without_enc('Blt_ActiveLegend', @path)
+ self
+ end
+ def crosshairs
+ tk_call_without_enc('Blt_Crosshairs', @path)
+ self
+ end
+ def zoom_stack
+ tk_call_without_enc('Blt_ZoomStack', @path)
+ self
+ end
+ def print_key
+ tk_call_without_enc('Blt_PrintKey', @path)
+ self
+ end
+ def closest_point
+ tk_call_without_enc('Blt_ClosestPoint', @path)
+ self
+ end
+ end
+
+ ####################################################
+
+ autoload :PlotComponent,'tkextlib/blt/component.rb'
+
+ autoload :Barchart, 'tkextlib/blt/barchart.rb'
+ autoload :Bitmap, 'tkextlib/blt/bitmap.rb'
+ autoload :Busy, 'tkextlib/blt/busy.rb'
+ autoload :Container, 'tkextlib/blt/container.rb'
+ autoload :CutBuffer, 'tkextlib/blt/cutbuffer.rb'
+ autoload :DragDrop, 'tkextlib/blt/dragdrop.rb'
+ autoload :EPS, 'tkextlib/blt/eps.rb'
+ autoload :Htext, 'tkextlib/blt/htext.rb'
+ autoload :Graph, 'tkextlib/blt/graph.rb'
+ autoload :Spline, 'tkextlib/blt/spline.rb'
+ autoload :Stripchart, 'tkextlib/blt/stripchart.rb'
+ autoload :Table, 'tkextlib/blt/table.rb'
+ autoload :Tabnotebook, 'tkextlib/blt/tabnotebook.rb'
+ autoload :Tabset, 'tkextlib/blt/tabset.rb'
+ autoload :Ted, 'tkextlib/blt/ted.rb'
+ autoload :Tile, 'tkextlib/blt/tile.rb'
+ autoload :Tree, 'tkextlib/blt/tree.rb'
+ autoload :TreeView, 'tkextlib/blt/treeview.rb'
+ autoload :Hiertable, 'tkextlib/blt/treeview.rb'
+ # Hierbox is obsolete
+ autoload :Vector, 'tkextlib/blt/vector.rb'
+ autoload :VectorAccess, 'tkextlib/blt/vector.rb'
+ autoload :Watch, 'tkextlib/blt/watch.rb'
+ autoload :Winop, 'tkextlib/blt/winop.rb'
+ autoload :WinOp, 'tkextlib/blt/winop.rb'
+
+ # Unix only
+ autoload :DnD, 'tkextlib/blt/unix_dnd.rb'
+
+ # Windows only
+ autoload :Printer, 'tkextlib/blt/win_printer.rb'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb
new file mode 100644
index 0000000..a86b91c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb
@@ -0,0 +1,79 @@
+#
+# tkextlib/blt/barchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/component.rb'
+
+module Tk::BLT
+ class Barchart < TkWindow
+ TkCommandNames = ['::blt::barchart'.freeze].freeze
+ WidgetClassName = 'Barchart'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include PlotComponent
+ include GraphCommand
+
+ def __boolval_optkeys
+ ['bufferelements', 'buffergraph', 'invertxy']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ ['text', 'label', 'title', 'file',
+ 'background', 'plotbackground']
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'colormap' << 'fontmap'
+ end
+ private :__tkvariable_optkeys
+
+=begin
+ BarElement_ID = ['blt_barchart_bar'.freeze, TkUtil.untrust('00000')].freeze
+
+ def bar(elem=nil, keys={})
+ if elem.kind_of?(Hash)
+ keys = elem
+ elem = nil
+ end
+ unless elem
+ elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
+ BarElement_ID[1].succ!
+ end
+ tk_send('bar', elem, keys)
+ Element.new(self, elem, :without_creating=>true)
+ end
+=end
+
+ def extents(item)
+ num_or_str(tk_send_without_enc('extents', item))
+ end
+
+ def invtransform(x, y)
+ list(tk_send_without_enc('invtransform', x, y))
+ end
+
+ def inside(x, y)
+ bool(tk_send_without_enc('inside', x, y))
+ end
+
+ def metafile(file=None)
+ # Windows only
+ tk_send('metafile', file)
+ self
+ end
+
+ def snap(output, keys={})
+ tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
+ self
+ end
+
+ def transform(x, y)
+ list(tk_send_without_enc('transform', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb
new file mode 100644
index 0000000..3254b63
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb
@@ -0,0 +1,112 @@
+#
+# tkextlib/blt/bitmap.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Bitmap < TkObject
+ extend TkCore
+
+ TkCommandNames = ['::blt::bitmap'.freeze].freeze
+
+ BITMAP_ID_TBL = TkCore::INTERP.create_table
+
+ (BITMAP_ID = ['blt_bitmap_id'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ BITMAP_ID_TBL.mutex.synchronize{ BITMAP_ID_TBL.clear }
+ }
+
+ def self.data(name)
+ dat = tk_simple_list(tk_call('::blt::bitmap', 'data', name))
+ [ tk_split_list(dat[0]), tk_simple_list(dat[1]) ]
+ end
+
+ def self.exist?(name)
+ bool(tk_call('::blt::bitmap', 'exists', name))
+ end
+
+ def self.height(name)
+ number(tk_call('::blt::bitmap', 'height', name))
+ end
+
+ def self.width(name)
+ number(tk_call('::blt::bitmap', 'width', name))
+ end
+
+ def self.source(name)
+ tk_simple_list(tk_call('::blt::bitmap', 'source', name))
+ end
+
+ #################################
+
+ class << self
+ alias _new new
+
+ def new(data, keys={})
+ _new(:data, nil, data, keys)
+ end
+ alias define new
+
+ def new_with_name(name, data, keys={})
+ _new(:data, name, data, keys)
+ end
+ alias define_with_name new_with_name
+
+ def compose(text, keys={})
+ _new(:text, nil, text, keys)
+ end
+
+ def compose_with_name(name, text, keys={})
+ _new(:text, name, text, keys)
+ end
+ end
+
+ def initialize(type, name, data, keys = {})
+ if name
+ @id = name
+ else
+ BITMAP_ID.mutex.synchronize{
+ @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
+ BITMAP_ID[1].succ!
+ }
+ BITMAP_ID_TBL.mutex.synchronize{
+ BITMAP_ID_TBL[@id] = self
+ }
+ end
+
+ @path = @id
+
+ unless bool(tk_call('::blt::bitmap', 'exists', @id))
+ if type == :text
+ tk_call('::blt::bitmap', 'compose', @id, data, *hash_kv(keys))
+ else # :data
+ tk_call('::blt::bitmap', 'define', @id, data, *hash_kv(keys))
+ end
+ end
+ end
+
+ def exist?
+ bool(tk_call('::blt::bitmap', 'exists', @id))
+ end
+
+ def height
+ number(tk_call('::blt::bitmap', 'height', @id))
+ end
+
+ def width
+ number(tk_call('::blt::bitmap', 'width', @id))
+ end
+
+ def source
+ tk_simple_list(tk_call('::blt::bitmap', 'source', @id))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb
new file mode 100644
index 0000000..b5287fb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb
@@ -0,0 +1,83 @@
+#
+# tkextlib/blt/busy.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig.rb'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Busy
+ extend TkCore
+ extend TkItemConfigMethod
+
+ TkCommandNames = ['::blt::busy'.freeze].freeze
+
+ ###########################
+
+ class Shield < TkWindow
+ def self.shield_path(win)
+ win = window(win) unless win.kind_of?(TkWindow)
+ if win.kind_of?(Tk::Toplevel)
+ win.path + '._Busy'
+ else
+ win.path + '_Busy'
+ end
+ end
+
+ def initialize(win)
+ @path = self.class.shield_path(win)
+ end
+ end
+
+ def self.shield_path(win)
+ Tk::BLT::Busy::Shield.shield_path(win)
+ end
+ end
+end
+
+class << Tk::BLT::Busy
+ def __item_config_cmd(win)
+ ['::blt::busy', 'configure', win]
+ end
+ private :__item_config_cmd
+
+ undef itemcget
+ undef itemcget_tkstring
+ alias configure itemconfigure
+ alias configinfo itemconfiginfo
+ alias current_configinfo current_itemconfiginfo
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ##################################
+
+ def hold(win, keys={})
+ tk_call('::blt::busy', 'hold', win, *hash_kv(keys))
+ end
+
+ def release(*wins)
+ tk_call('::blt::busy', 'release', *wins)
+ end
+
+ def forget(*wins)
+ tk_call('::blt::busy', 'forget', *wins)
+ end
+
+ def is_busy(pat=None)
+ tk_split_list(tk_call('::blt::busy', 'isbusy', pat))
+ end
+
+ def names(pat=None)
+ tk_split_list(tk_call('::blt::busy', 'names', pat))
+ end
+ alias windows names
+
+ def check(win)
+ bool(tk_call('::blt::busy', 'check', win))
+ end
+
+ def status(win)
+ bool(tk_call('::blt::busy', 'status', win))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/component.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/component.rb
new file mode 100644
index 0000000..c7ea213
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/component.rb
@@ -0,0 +1,2218 @@
+#
+# tkextlib/blt/component.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module PlotComponent
+ include TkItemConfigMethod
+
+ module OptKeys
+ def __item_font_optkeys(id)
+ ['font', 'tickfont', 'titlefont']
+ end
+ private :__item_font_optkeys
+
+ def __item_numstrval_optkeys(id)
+ ['xoffset', 'yoffset']
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_boolval_optkeys(id)
+ ['hide', 'under', 'descending', 'logscale', 'loose', 'showticks',
+ 'titlealternate', 'scalesymbols', 'minor', 'raised',
+ 'center', 'decoration', 'landscape', 'maxpect']
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ ['text', 'label', 'limits', 'title',
+ 'show', 'file', 'maskdata', 'maskfile',
+ 'color', 'titlecolor', 'fill', 'outline', 'offdash']
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ ['bindtags']
+ end
+ private :__item_listval_optkeys
+
+ def __item_numlistval_optkeys(id)
+ ['dashes', 'majorticks', 'minorticks']
+ end
+ private :__item_numlistval_optkeys
+
+ def __item_tkvariable_optkeys(id)
+ ['variable', 'textvariable', 'colormap', 'fontmap']
+ end
+ private :__item_tkvariable_optkeys
+ end
+
+ include OptKeys
+
+ def __item_cget_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name ]
+ [self.path, id[0], 'cget', id[1]]
+ else
+ [self.path, id, 'cget']
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name, ... ]
+ type, *names = id
+ [self.path, type, 'configure'].concat(names)
+ else
+ [self.path, id, 'configure']
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def axis_cget_tkstring(id, option)
+ ret = itemcget_tkstring(['axis', tagid(id)], option)
+ end
+ def axis_cget(id, option)
+ ret = itemcget(['axis', tagid(id)], option)
+ end
+ def axis_cget_strict(id, option)
+ ret = itemcget_strict(['axis', tagid(id)], option)
+ end
+ def axis_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ else
+ value = slot
+ slot = args.pop
+ if slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('axis')
+ itemconfigure(id_list, slot, value)
+ end
+ def axis_configinfo(id, slot=nil)
+ itemconfiginfo(['axis', tagid(id)], slot)
+ end
+ def current_axis_configinfo(id, slot=nil)
+ current_itemconfiginfo(['axis', tagid(id)], slot)
+ end
+
+ def crosshairs_cget_tkstring(option)
+ itemcget_tkstring('crosshairs', option)
+ end
+ def crosshairs_cget(option)
+ itemcget('crosshairs', option)
+ end
+ def crosshairs_cget_strict(option)
+ itemcget_strict('crosshairs', option)
+ end
+ def crosshairs_configure(slot, value=None)
+ itemconfigure('crosshairs', slot, value)
+ end
+ def crosshairs_configinfo(slot=nil)
+ itemconfiginfo('crosshairs', slot)
+ end
+ def current_crosshairs_configinfo(slot=nil)
+ current_itemconfiginfo('crosshairs', slot)
+ end
+
+ def element_cget_tkstring(id, option)
+ itemcget_tkstring(['element', tagid(id)], option)
+ end
+ def element_cget(id, option)
+ itemcget(['element', tagid(id)], option)
+ end
+ def element_cget_strict(id, option)
+ itemcget_strict(['element', tagid(id)], option)
+ end
+ def element_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('element')
+ itemconfigure(id_list, slot, value)
+ end
+ def element_configinfo(id, slot=nil)
+ itemconfiginfo(['element', tagid(id)], slot)
+ end
+ def current_element_configinfo(id, slot=nil)
+ current_itemconfiginfo(['element', tagid(id)], slot)
+ end
+
+ def bar_cget_tkstring(id, option)
+ itemcget_tkstring(['bar', tagid(id)], option)
+ end
+ def bar_cget(id, option)
+ itemcget(['bar', tagid(id)], option)
+ end
+ def bar_cget_strict(id, option)
+ itemcget_strict(['bar', tagid(id)], option)
+ end
+ def bar_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('bar')
+ itemconfigure(id_list, slot, value)
+ end
+ def bar_configinfo(id, slot=nil)
+ itemconfiginfo(['bar', tagid(id)], slot)
+ end
+ def current_bar_configinfo(id, slot=nil)
+ current_itemconfiginfo(['bar', tagid(id)], slot)
+ end
+
+ def line_cget_tkstring(id, option)
+ itemcget_tkstring(['line', tagid(id)], option)
+ end
+ def line_cget(id, option)
+ itemcget(['line', tagid(id)], option)
+ end
+ def line_cget_strict(id, option)
+ itemcget_strict(['line', tagid(id)], option)
+ end
+ def line_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('line')
+ itemconfigure(id_list, slot, value)
+ end
+ def line_configinfo(id, slot=nil)
+ itemconfiginfo(['line', tagid(id)], slot)
+ end
+ def current_line_configinfo(id, slot=nil)
+ current_itemconfiginfo(['line', tagid(id)], slot)
+ end
+
+ def gridline_cget_tkstring(option)
+ itemcget_tkstring('grid', option)
+ end
+ def gridline_cget(option)
+ itemcget('grid', option)
+ end
+ def gridline_cget_strict(option)
+ itemcget_strict('grid', option)
+ end
+ def gridline_configure(slot, value=None)
+ itemconfigure('grid', slot, value)
+ end
+ def gridline_configinfo(slot=nil)
+ itemconfiginfo('grid', slot)
+ end
+ def current_gridline_configinfo(slot=nil)
+ current_itemconfiginfo('grid', slot)
+ end
+
+ def legend_cget_tkstring(option)
+ itemcget_tkstring('legend', option)
+ end
+ def legend_cget(option)
+ itemcget('legend', option)
+ end
+ def legend_cget_strict(option)
+ itemcget_strict('legend', option)
+ end
+ def legend_configure(slot, value=None)
+ itemconfigure('legend', slot, value)
+ end
+ def legend_configinfo(slot=nil)
+ itemconfiginfo('legend', slot)
+ end
+ def current_legend_configinfo(slot=nil)
+ current_itemconfiginfo('legend', slot)
+ end
+
+ def pen_cget_tkstring(id, option)
+ itemcget_tkstring(['pen', tagid(id)], option)
+ end
+ def pen_cget(id, option)
+ itemcget(['pen', tagid(id)], option)
+ end
+ def pen_cget_strict(id, option)
+ itemcget_strict(['pen', tagid(id)], option)
+ end
+ def pen_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('pen')
+ itemconfigure(id_list, slot, value)
+ end
+ def pen_configinfo(id, slot=nil)
+ itemconfiginfo(['pen', tagid(id)], slot)
+ end
+ def current_pen_configinfo(id, slot=nil)
+ current_itemconfiginfo(['pen', tagid(id)], slot)
+ end
+
+ def postscript_cget_tkstring(option)
+ itemcget_tkstring('postscript', option)
+ end
+ def postscript_cget(option)
+ itemcget('postscript', option)
+ end
+ def postscript_cget_strict(option)
+ itemcget_strict('postscript', option)
+ end
+ def postscript_configure(slot, value=None)
+ itemconfigure('postscript', slot, value)
+ end
+ def postscript_configinfo(slot=nil)
+ itemconfiginfo('postscript', slot)
+ end
+ def current_postscript_configinfo(slot=nil)
+ current_itemconfiginfo('postscript', slot)
+ end
+
+ def marker_cget_tkstring(id, option)
+ itemcget_tkstring(['marker', tagid(id)], option)
+ end
+ def marker_cget(id, option)
+ itemcget(['marker', tagid(id)], option)
+ end
+ def marker_cget_strict(id, option)
+ itemcget_strict(['marker', tagid(id)], option)
+ end
+ def marker_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('marker')
+ itemconfigure(id_list, slot, value)
+ end
+ def marker_configinfo(id, slot=nil)
+ itemconfiginfo(['marker', tagid(id)], slot)
+ end
+ def current_marker_configinfo(id, slot=nil)
+ current_itemconfiginfo(['marker', tagid(id)], slot)
+ end
+
+ alias __itemcget_tkstring itemcget_tkstring
+ alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+ private :__itemcget_tkstring, :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo
+
+ def itemcget_tkstring(tagOrId, option)
+ __itemcget_tkstring(tagid(tagOrId), option)
+ end
+ def itemcget_strict(tagOrId, option)
+ ret = __itemcget(tagid(tagOrId), option)
+ if option == 'bindtags' || option == :bindtags
+ ret.collect{|tag| TkBindTag.id2obj(tag)}
+ else
+ ret
+ end
+ end
+ def itemcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ itemcget_strict(tagOrId, option)
+ else
+ begin
+ itemcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_itemconfiginfo(tagOrId).has_key?(option.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ def itemconfiginfo(tagOrId, slot = nil)
+ ret = __itemconfiginfo(tagid(tagOrId), slot)
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ if slot == 'bindtags' || slot == :bindtags
+ ret[-2] = ret[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ ret[-1] = ret[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+ else
+ if (inf = ret.assoc('bindtags'))
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = ret['bindtags'])
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ ret['bindtags'] = inf
+ end
+ end
+
+ ret
+ end
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ ret = __current_itemconfiginfo(tagid(tagOrId), slot)
+
+ if (val = ret['bindtags'])
+ ret['bindtags'] = val.collect{|tag| TkBindTag.id2obj(tag)}
+ end
+
+ ret
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ #################
+
+ class Axis < TkObject
+ (OBJ_ID = ['blt_chart_axis'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ AxisID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ AxisID_TBL.mutex.synchronize{ AxisID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ cpath = chart.path
+ AxisID_TBL.mutex.synchronize{
+ return id unless AxisID_TBL[cpath]
+ AxisID_TBL[cpath][id]? AxisID_TBL[cpath][id]: id
+ }
+ end
+
+ def self.new(chart, axis=nil, keys={})
+ if axis.kind_of?(Hash)
+ keys = axis
+ axis = nil
+ end
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ AxisID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ AxisID_TBL[chart_path] ||= {}
+ if axis && AxisID_TBL[chart_path][axis]
+ obj = AxisID_TBL[chart_path][axis]
+ else
+ (obj = self.allocate).instance_eval{
+ if axis
+ @axis = @id = axis.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Axis::AxisID_TBL[@cpath][@axis] = self
+ unless not_create
+ tk_call(@chart, 'axis', 'create', @axis, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, axis=nil, keys={})
+ # dummy:: not called by 'new' method
+
+ if axis.kind_of?(Hash)
+ keys = axis
+ axis = nil
+ end
+ if axis
+ @axis = @id = axis.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Axis::AxisID_TBL[@cpath][@axis] = self
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ # @chart.axis_create(@axis, keys)
+ tk_call(@chart, 'axis', 'create', @axis, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.axis_cget_tkstring(@id, option)
+ end
+ def cget(option)
+ @chart.axis_cget(@id, option)
+ end
+ def cget_strict(option)
+ @chart.axis_cget_strict(@id, option)
+ end
+ def configure(key, value=None)
+ @chart.axis_configure(@id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.axis_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_axis_configinfo(@id, key)
+ end
+
+ def command(cmd=nil, &b)
+ if cmd
+ configure('command', cmd)
+ elsif b
+ configure('command', Proc.new(&b))
+ else
+ cget('command')
+ end
+ end
+
+ def delete
+ @chart.axis_delete(@id)
+ self
+ end
+
+ def invtransform(val)
+ @chart.axis_invtransform(@id, val)
+ end
+
+ def limits
+ @chart.axis_limits(@id)
+ end
+
+ def name
+ @axis
+ end
+
+ def transform(val)
+ @chart.axis_transform(@id, val)
+ end
+
+ def view
+ @chart.axis_view(@id)
+ self
+ end
+
+ def use(name=None) # if @id == xaxis | x2axis | yaxis | y2axis
+ @chart.axis_use(@id, name)
+ end
+
+ def use_as(axis) # axis := xaxis | x2axis | yaxis | y2axis
+ @chart.axis_use(axis, @id)
+ end
+ end
+
+ #################
+
+ class Crosshairs < TkObject
+ CrosshairsID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ CrosshairsID_TBL.mutex.synchronize{ CrosshairsID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ CrosshairsID_TBL.mutex.synchronize{
+ unless (obj = CrosshairsID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'crosshairs'
+ Crosshairs::CrosshairsID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.crosshair_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Crosshairs::CrosshairsID_TBL[@cpath] = self
+ @chart.crosshair_configure(keys) unless keys.empty?
+ @path = @id = 'crosshairs'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.crosshair_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.crosshair_cget(option)
+ end
+ def cget_strict(option)
+ @chart.crosshair_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.crosshair_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.crosshair_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_crosshair_configinfo(key)
+ end
+
+ def off
+ @chart.crosshair_off
+ self
+ end
+ def on
+ @chart.crosshair_on
+ self
+ end
+ def toggle
+ @chart.crosshair_toggle
+ self
+ end
+ end
+
+ #################
+
+ class Element < TkObject
+ extend Tk
+ extend TkItemFontOptkeys
+ extend TkItemConfigOptkeys
+
+ extend Tk::BLT::PlotComponent::OptKeys
+
+ ElementTypeName = 'element'
+ ElementTypeToClass = { ElementTypeName=>self }
+
+ ElementID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear }
+ }
+
+ (OBJ_ID = ['blt_chart_element'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ def Element.type2class(type)
+ ElementTypeToClass[type]
+ end
+
+ def Element.id2obj(chart, id)
+ cpath = chart.path
+ ElementID_TBL.mutex.synchronize{
+ return id unless ElementID_TBL[cpath]
+ ElementID_TBL[cpath][id]? ElementID_TBL[cpath][id]: id
+ }
+ end
+
+ def self.new(chart, element=nil, keys={})
+ if element.kind_of?(Hash)
+ keys = element
+ element = nil
+ end
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ ElementID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ ElementID_TBL[chart_path] ||= {}
+ if element && ElementID_TBL[chart_path][element]
+ obj = ElementID_TBL[chart_path][element]
+ else
+ (obj = self.allocate).instance_eval{
+ if element
+ @element = @id = element.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @typename = self.class::ElementTypeName
+ Element::ElementID_TBL[@cpath][@element] = self
+ unless not_create
+ tk_call(@chart, @typename, 'create', @element, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, element=nil, keys={})
+ # dummy:: not called by 'new' method
+
+ if element.kind_of?(Hash)
+ keys = element
+ element = nil
+ end
+ if element
+ @element = @id = element.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @typename = self.class::ElementTypeName
+ # Element::ElementID_TBL[@cpath][@element] = self
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ # @chart.element_create(@element, keys)
+ tk_call(@chart, @typename, 'create', @element, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ # @chart.element_cget(@id, option)
+ @chart.__send__(@typename + '_cget_tkstring', @id, option)
+ end
+ def cget(option)
+ # @chart.element_cget(@id, option)
+ @chart.__send__(@typename + '_cget', @id, option)
+ end
+ def cget_strict(option)
+ @chart.__send__(@typename + '_cget_strict', @id, option)
+ end
+ def configure(key, value=None)
+ # @chart.element_configure(@id, key, value)
+ @chart.__send__(@typename + '_configure', @id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ # @chart.element_configinfo(@id, key)
+ @chart.__send__(@typename + '_configinfo', @id, key)
+ end
+ def current_configinfo(key=nil)
+ # @chart.current_element_configinfo(@id, key)
+ @chart.__send__('current_' << @typename << '_configinfo', @id, key)
+ end
+
+ def activate(*args)
+ @chart.element_activate(@id, *args)
+ end
+
+ def closest(x, y, var, keys={})
+ # @chart.element_closest(x, y, var, @id, keys)
+ @chart.__send__(@typename + '_closest', x, y, var, @id, keys)
+ end
+
+ def deactivate
+ @chart.element_deactivate(@id)
+ self
+ end
+
+ def delete
+ @chart.element_delete(@id)
+ self
+ end
+
+ def exist?
+ @chart.element_exist?(@id)
+ end
+
+ def name
+ @element
+ end
+
+ def type
+ @chart.element_type(@id)
+ end
+ end
+
+ class Bar < Element
+ ElementTypeName = 'bar'.freeze
+ ElementTypeToClass[ElementTypeName] = self
+ end
+ class Line < Element
+ ElementTypeName = 'line'.freeze
+ ElementTypeToClass[ElementTypeName] = self
+ end
+
+ #################
+
+ class GridLine < TkObject
+ GridLineID_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{
+ GridLineID_TBL.mutex.synchronize{ GridLineID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ GridLineID_TBL.mutex.synchronize{
+ unless (obj = GridLineID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'grid'
+ GridLine::GridLineID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.gridline_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # GridLine::GridLineID_TBL[@cpath] = self
+ @chart.gridline_configure(keys) unless keys.empty?
+ @path = @id = 'grid'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.gridline_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.gridline_cget(option)
+ end
+ def cget_strict(option)
+ @chart.gridline_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.gridline_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.gridline_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_gridline_configinfo(key)
+ end
+
+ def off
+ @chart.gridline_off
+ self
+ end
+ def on
+ @chart.gridline_on
+ self
+ end
+ def toggle
+ @chart.gridline_toggle
+ self
+ end
+ end
+
+ #################
+
+ class Legend < TkObject
+ LegendID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ LegendID_TBL.mutex.synchronize{ LegendID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ LegenedID_TBL.mutex.synchronize{
+ unless (obj = LegenedID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'crosshairs'
+ Legend::LegenedID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.legend_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Legend::LegendID_TBL[@cpath] = self
+ @chart.legend_configure(keys) unless keys.empty?
+ @path = @id = 'legend'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.legend_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.legend_cget(option)
+ end
+ def cget_strict(option)
+ @chart.legend_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.legend_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.legend_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_legend_configinfo(key)
+ end
+
+ def activate(*args)
+ @chart.legend_activate(*args)
+ end
+
+ def deactivate(*args)
+ @chart.legend_deactivate(*args)
+ end
+
+ def get(pos, y=nil)
+ @chart.legend_get(pos, y)
+ end
+ end
+
+ #################
+
+ class Pen < TkObject
+ (OBJ_ID = ['blt_chart_pen'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ PenID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PenID_TBL.mutex.synchronize{ PenID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ cpath = chart.path
+ PenID_TBL.mutex.synchronize{
+ return id unless PenID_TBL[cpath]
+ PenID_TBL[cpath][id]? PenID_TBL[cpath][id]: id
+ }
+ end
+
+ def self.new(chart, pen=nil, keys={})
+ if pen.kind_of?(Hash)
+ keys = pen
+ pen = nil
+ end
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ PenID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ PenID_TBL[chart_path] ||= {}
+ if pen && PenID_TBL[chart_path][pen]
+ obj = PenID_TBL[chart_path][pen]
+ else
+ (obj = self.allocate).instance_eval{
+ if pen
+ @pen = @id = pen.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Pen::PenID_TBL[@cpath][@pen] = self
+ unless not_create
+ tk_call(@chart, 'pen', 'create', @pen, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, pen=nil, keys={})
+ if pen.kind_of?(Hash)
+ keys = pen
+ pen = nil
+ end
+ if pen
+ @pen = @id = pen.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Pen::PenID_TBL[@cpath][@pen] = self
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ # @chart.pen_create(@pen, keys)
+ tk_call(@chart, 'pen', 'create', @pen, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.pen_cget_tkstring(@id, option)
+ end
+ def cget(option)
+ @chart.pen_cget(@id, option)
+ end
+ def cget_strict(option)
+ @chart.pen_cget_strict(@id, option)
+ end
+ def configure(key, value=None)
+ @chart.pen_configure(@id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.pen_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_pen_configinfo(@id, key)
+ end
+
+ def delete
+ @chart.pen_delete(@id)
+ self
+ end
+
+ def name
+ @pen
+ end
+ end
+
+ #################
+
+ class Postscript < TkObject
+ PostscriptID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PostscriptID_TBL.mutex.synchronize{ PostscriptID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ PostscriptID_TBL.mutex.synchronize{
+ unless (obj = PostscriptID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'postscript'
+ Postscript::PostscriptID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.postscript_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Postscript::PostscriptID_TBL[@cpath] = self
+ @chart.postscript_configure(keys) unless keys.empty?
+ @path = @id = 'postscript'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.postscript_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.postscript_cget(option)
+ end
+ def cget_strict(option)
+ @chart.postscript_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.postscript_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.postscript_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_postscript_configinfo(key)
+ end
+
+ def output(file=nil, keys={})
+ if file.kind_of?(Hash)
+ keys = file
+ file = nil
+ end
+
+ ret = @chart.postscript_output(file, keys)
+
+ if file
+ self
+ else
+ ret
+ end
+ end
+ end
+
+ #################
+ class Marker < TkObject
+ extend Tk
+ extend TkItemFontOptkeys
+ extend TkItemConfigOptkeys
+
+ extend Tk::BLT::PlotComponent::OptKeys
+
+ MarkerTypeName = nil
+ MarkerTypeToClass = {}
+ MarkerID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ MarkerID_TBL.mutex.synchronize{ MarkerID_TBL.clear }
+ }
+
+ def Marker.type2class(type)
+ MarkerTypeToClass[type]
+ end
+
+ def Marker.id2obj(chart, id)
+ cpath = chart.path
+ MarkerID_TBL.mutex.synchronize{
+ if MarkerID_TBL[cpath]
+ MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self._parse_create_args(keys)
+ fontkeys = {}
+ methodkeys = {}
+ if keys.kind_of? Hash
+ keys = _symbolkey2str(keys)
+
+ __item_font_optkeys(nil).each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
+
+ __item_optkey_aliases(nil).each{|alias_name, real_name|
+ alias_name = alias_name.to_s
+ if keys.has_key?(alias_name)
+ keys[real_name.to_s] = keys.delete(alias_name)
+ end
+ }
+
+ __item_methodcall_optkeys(nil).each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
+
+ __item_ruby2val_optkeys(nil).each{|key, method|
+ key = key.to_s
+ keys[key] = method.call(keys[key]) if keys.has_key?(key)
+ }
+
+ args = itemconfig_hash_kv(nil, keys)
+ else
+ args = []
+ end
+
+ [args, fontkeys, methodkeys]
+ end
+ private_class_method :_parse_create_args
+
+ def self.create(chart, keys={})
+ unless self::MarkerTypeName
+ fail RuntimeError, "#{self} is an abstract class"
+ end
+ args, fontkeys, methodkeys = _parse_create_args(keys)
+ idnum = tk_call_without_enc(chart.path, 'marker', 'create',
+ self::MarkerTypeName, *args)
+ chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
+ chart.marker_configure(idnum, methodkeys) unless methodkeys.empty?
+ idnum.to_i # 'item id' is an integer number
+ end
+
+ def self.create_type(chart, type, keys={})
+ args, fontkeys, methodkeys = _parse_create_args(keys)
+ idnum = tk_call_without_enc(chart.path, 'marker', 'create',
+ type, *args)
+ chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
+ chart.marker_configure(idnum, methodkeys) unless methodkeys.empty?
+ id = idnum.to_i # 'item id' is an integer number
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @chart = chart
+ @cpath = chart.path
+ @id = id
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ }
+ }
+ obj
+ end
+
+ def initialize(parent, *args)
+ @parent = @chart = parent
+ @cpath = parent.path
+
+ @path = @id = create_self(*args) # an integer number as 'item id'
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ }
+ end
+ def create_self(*args)
+ self.class.create(@chart, *args) # return an integer as 'item id'
+ end
+ private :create_self
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.marker_cget_tkstring(@id, option)
+ end
+ def cget(option)
+ @chart.marker_cget(@id, option)
+ end
+ def cget_strict(option)
+ @chart.marker_cget_strict(@id, option)
+ end
+ def configure(key, value=None)
+ @chart.marker_configure(@id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.marker_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_marker_configinfo(@id, key)
+ end
+
+ def after(target=None)
+ @chart.marker_after(@id, target)
+ end
+
+ def before(target=None)
+ @chart.marker_before(@id, target)
+ end
+
+ def delete
+ @chart.marker_delete(@id)
+ end
+
+ def exist?
+ @chart.marker_exist(@id)
+ end
+
+ def type
+ @chart.marker_type(@id)
+ end
+ end
+
+ class TextMarker < Marker
+ MarkerTypeName = 'text'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class LineMarker < Marker
+ MarkerTypeName = 'line'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class BitmapMarker < Marker
+ MarkerTypeName = 'bitmap'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class ImageMarker < Marker
+ MarkerTypeName = 'image'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class PolygonMarker < Marker
+ MarkerTypeName = 'polygon'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class WindowMarker < Marker
+ MarkerTypeName = 'window'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+
+ #################
+
+ def __destroy_hook__
+ Axis::AxisID_TBL.delete(@path)
+ Crosshairs::CrosshairsID_TBL.delete(@path)
+ Element::ElementID_TBL.delete(@path)
+ GridLine::GridLineID_TBL.delete(@path)
+ Legend::LegendID_TBL.delete(@path)
+ Pen::PenID_TBL.delete(@path)
+ Postscript::PostscriptID_TBL.delete(@path)
+ Marker::MarkerID_TBL.delete(@path)
+ super()
+ end
+
+ #################
+
+ def tagid(tag)
+ if tag.kind_of?(Axis) ||
+ tag.kind_of?(Crosshairs) ||
+ tag.kind_of?(Element) ||
+ tag.kind_of?(GridLine) ||
+ tag.kind_of?(Legend) ||
+ tag.kind_of?(Pen) ||
+ tag.kind_of?(Postscript) ||
+ tag.kind_of?(Marker)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+
+ def _component_bind(target, tag, context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, target, 'bind', tagid(tag)], context, cmd, *args)
+ self
+ end
+ def _component_bind_append(target, tag, context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, target, 'bind', tagid(tag)], context, cmd, *args)
+ self
+ end
+ def _component_bind_remove(target, tag, context)
+ _bind_remove([path, target, 'bind', tagid(tag)], context)
+ self
+ end
+ def _component_bindinfo(target, tag, context=nil)
+ _bindinfo([path, target, 'bind', tagid(tag)], context)
+ end
+ private :_component_bind, :_component_bind_append
+ private :_component_bind_remove, :_component_bindinfo
+
+ def axis_bind(tag, context, *args)
+ _component_bind('axis', tag, context, *args)
+ end
+ def axis_bind_append(tag, context, *args)
+ _component_bind_append('axis', tag, context, *args)
+ end
+ def axis_bind_remove(tag, context)
+ _component_bind_remove('axis', tag, context)
+ end
+ def axis_bindinfo(tag, context=nil)
+ _component_bindinfo('axis', tag, context)
+ end
+
+ def element_bind(tag, context, *args)
+ _component_bind('element', tag, context, *args)
+ end
+ def element_bind_append(tag, context, *args)
+ _component_bind_append('element', tag, context, *args)
+ end
+ def element_bind_remove(tag, context)
+ _component_bind_remove('element', tag, context)
+ end
+ def element_bindinfo(tag, context=nil)
+ _component_bindinfo('element', tag, context)
+ end
+
+ def bar_bind(tag, context, *args)
+ _component_bind('bar', tag, context, *args)
+ end
+ def bar_bind_append(tag, context, *args)
+ _component_bind_append('bar', tag, context, *args)
+ end
+ def bar_bind_remove(tag, context)
+ _component_bind_remove('bar', tag, context)
+ end
+ def bar_bindinfo(tag, context=nil)
+ _component_bindinfo('bar', tag, context)
+ end
+
+ def line_bind(tag, context, *args)
+ _component_bind('line', tag, context, *args)
+ end
+ def line_bind_append(tag, context, *args)
+ _component_bind_append('line', tag, context, *args)
+ end
+ def line_bind_remove(tag, context)
+ _component_bind_remove('line', tag, context)
+ end
+ def line_bindinfo(tag, context=nil)
+ _component_bindinfo('line', tag, context)
+ end
+
+ def legend_bind(tag, context, *args)
+ _component_bind('legend', tag, context, *args)
+ end
+ def legend_bind_append(tag, context, *args)
+ _component_bind_append('legend', tag, context, *args)
+ end
+ def legend_bind_remove(tag, context)
+ _component_bind_remove('legend', tag, context)
+ end
+ def legend_bindinfo(tag, context=nil)
+ _component_bindinfo('legend', tag, context)
+ end
+
+ def marker_bind(tag, context, *args)
+ _component_bind('marker', tag, context, *args)
+ end
+ def marker_bind_append(tag, context, *args)
+ _component_bind_append('marker', tag, context, *args)
+ end
+ def marker_bind_remove(tag, context)
+ _component_bind_remove('marker', tag, context)
+ end
+ def marker_bindinfo(tag, context=nil)
+ _component_bindinfo('marker', tag, context)
+ end
+
+ ###################
+
+ def axis_create(id=nil, keys={})
+ # tk_send('axis', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Axis.new(self, tagid(id), keys)
+ end
+ def axis_delete(*ids)
+ tk_send('axis', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def axis_invtransform(id, val)
+ list(tk_send('axis', 'invtransform', tagid(id), val))
+ end
+ def axis_limits(id)
+ list(tk_send('axis', 'limits', tagid(id)))
+ end
+ def axis_names(*pats)
+ simplelist(tk_send('axis', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|axis|
+ Tk::BLT::PlotComponent::Axis.id2obj(self, axis)
+ }
+ end
+ def axis_transform(id, val)
+ list(tk_send('axis', 'transform', tagid(id), val))
+ end
+ def axis_view(id)
+ tk_send('axis', 'view', tagid(id))
+ self
+ end
+ def axis_use(id, target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('axis', 'use',
+ tagid(id), tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('axis', 'use', tagid(id)))
+ end
+ end
+
+ ###################
+
+ def crosshairs_off
+ tk_send_without_enc('crosshairs', 'off')
+ self
+ end
+ def crosshairs_on
+ tk_send_without_enc('crosshairs', 'on')
+ self
+ end
+ def crosshairs_toggle
+ tk_send_without_enc('crosshairs', 'toggle')
+ self
+ end
+
+ ###################
+
+ def element_create(id=nil, keys={})
+ # tk_send('element', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Element.new(self, tagid(id), keys)
+ end
+ def element_activate(*args)
+ if args.empty?
+ list(tk_send('element', 'activate')).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ else
+ # id, *indices
+ id = args.shift
+ tk_send('element', 'activate', tagid(id), *args)
+ end
+ end
+ def element_closest(x, y, var, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ bool(tk_send('element', 'closest', x, y, var,
+ *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
+ else
+ bool(tk_send('element', 'closest', x, y, var,
+ *(args.collect{|id| tagid(id)})))
+ end
+ end
+ def element_deactivate(*ids)
+ tk_send('element', 'deactivate', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def element_delete(*ids)
+ tk_send('element', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def element_exist?(id)
+ bool(tk_send('element', 'exists', tagid(id)))
+ end
+ def element_names(*pats)
+ simplelist(tk_send('element', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def element_show(*names)
+ if names.empty?
+ simplelist(tk_send('element', 'show'))
+ else
+ tk_send('element', 'show', *(names.collect{|n| tagid(n)}))
+ self
+ end
+ end
+ def element_type(id)
+ tk_send('element', 'type', tagid(id))
+ end
+
+ ###################
+
+ def bar_create(id=nil, keys={})
+ # tk_send('bar', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Bar.new(self, tagid(id), keys)
+ end
+ alias bar bar_create
+ def bar_activate(*args)
+ if args.empty?
+ list(tk_send('bar', 'activate')).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ else
+ # id, *indices
+ id = args.shift
+ tk_send('bar', 'activate', tagid(id), *args)
+ end
+ end
+ def bar_closest(x, y, var, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ bool(tk_send('bar', 'closest', x, y, var,
+ *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
+ else
+ bool(tk_send('bar', 'closest', x, y, var,
+ *(args.collect{|id| tagid(id)})))
+ end
+ end
+ def bar_deactivate(*ids)
+ tk_send('bar', 'deactivate', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def bar_delete(*ids)
+ tk_send('bar', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def bar_exist?(id)
+ bool(tk_send('bar', 'exists', tagid(id)))
+ end
+ def bar_names(*pats)
+ simplelist(tk_send('bar', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def bar_show(*names)
+ if names.empty?
+ simplelist(tk_send('bar', 'show'))
+ else
+ tk_send('bar', 'show', *(names.collect{|n| tagid(n)}))
+ self
+ end
+ end
+ def bar_type(id)
+ tk_send('bar', 'type', tagid(id))
+ end
+
+ ###################
+
+ def line_create(id=nil, keys={})
+ # tk_send('line', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Line.new(self, tagid(id), keys)
+ end
+ alias bar line_create
+ def line_activate(*args)
+ if args.empty?
+ list(tk_send('line', 'activate')).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ else
+ # id, *indices
+ id = args.shift
+ tk_send('line', 'activate', tagid(id), *args)
+ end
+ end
+ def line_closest(x, y, var, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ bool(tk_send('line', 'closest', x, y, var,
+ *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
+ else
+ bool(tk_send('line', 'closest', x, y, var,
+ *(args.collect{|id| tagid(id)})))
+ end
+ end
+ def line_deactivate(*ids)
+ tk_send('line', 'deactivate', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def line_delete(*ids)
+ tk_send('line', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def line_exist?(id)
+ bool(tk_send('line', 'exists', tagid(id)))
+ end
+ def line_names(*pats)
+ simplelist(tk_send('line', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def line_show(*names)
+ if names.empty?
+ simplelist(tk_send('line', 'show'))
+ else
+ tk_send('line', 'show', *(names.collect{|n| tagid(n)}))
+ self
+ end
+ end
+ def line_type(id)
+ tk_send('line', 'type', tagid(id))
+ end
+
+ ###################
+
+ def gridline_off
+ tk_send_without_enc('grid', 'off')
+ self
+ end
+ def gridline_on
+ tk_send_without_enc('grid', 'on')
+ self
+ end
+ def gridline_toggle
+ tk_send_without_enc('grid', 'toggle')
+ self
+ end
+
+ ###################
+
+ def legend_window_create(parent=nil, keys=nil)
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ widgetname = keys.delete('widgetname')
+ keys.delete('without_creating')
+ elsif keys
+ keys = _symbolkey2str(keys)
+ widgetname = keys.delete('widgetname')
+ keys.delete('without_creating')
+ end
+
+ legend = self.class.new(parent, :without_creating=>true,
+ :widgetname=>widgetname)
+ class << legend
+ def __destroy_hook__
+ TkCore::INTERP.tk_windows.delete(@path)
+ end
+ end
+
+ if keys
+ self.legend_configure(keys.update('position'=>legend))
+ else
+ self.legend_configure('position'=>legend)
+ end
+ legend
+ end
+
+ def legend_activate(*pats)
+ list(tk_send('legend', 'activate',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def legend_deactivate(*pats)
+ list(tk_send('legend', 'deactivate',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def legend_get(pos, y=nil)
+ if y
+ Tk::BLT::PlotComponent::Element.id2obj(self,
+ tk_send('legend', 'get',
+ _at(pos, y)))
+ else
+ Tk::BLT::PlotComponent::Element.id2obj(self,
+ tk_send('legend', 'get', pos))
+ end
+ end
+
+ ###################
+
+ def pen_create(id=nil, keys={})
+ # tk_send('pen', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Pen.new(self, tagid(id), keys)
+ end
+ def pen_delete(*ids)
+ tk_send('pen', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def pen_names(*pats)
+ simplelist(tk_send('pen', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|pen|
+ Tk::BLT::PlotComponent::Pen.id2obj(self, pen)
+ }
+ end
+
+ ###################
+
+ def postscript_output(file=nil, keys={})
+ if file.kind_of?(Hash)
+ keys = file
+ file = nil
+ end
+
+ if file
+ tk_send('postscript', 'output', file, keys)
+ self
+ else
+ tk_send('postscript', 'output', keys)
+ end
+ end
+
+ ###################
+
+ def marker_create(type, keys={})
+ case type
+ when :text, 'text'
+ Tk::BLT::PlotComponent::TextMarker.new(self, keys)
+ when :line, 'line'
+ Tk::BLT::PlotComponent::LineMarker.new(self, keys)
+ when :bitmap, 'bitmap'
+ Tk::BLT::PlotComponent::BitmapMarker.new(self, keys)
+ when :image, 'image'
+ Tk::BLT::PlotComponent::ImageMarker.new(self, keys)
+ when :polygon, 'polygon'
+ Tk::BLT::PlotComponent::PolygonMarker.new(self, keys)
+ when :window, 'window'
+ Tk::BLT::PlotComponent::WindowMarker.new(self, keys)
+ else
+ if type.kind_of?(Tk::BLT::PlotComponent::Marker)
+ type.new(self, keys)
+ else
+ Tk::BLT::PlotComponent::Marker.create_type(self, type, keys)
+ end
+ end
+ end
+ def marker_after(id, target=nil)
+ if target
+ tk_send_without_enc('marker', 'after', tagid(id), tagid(target))
+ else
+ tk_send_without_enc('marker', 'after', tagid(id))
+ end
+ self
+ end
+ def marker_before(id, target=None)
+ if target
+ tk_send_without_enc('marker', 'before', tagid(id), tagid(target))
+ else
+ tk_send_without_enc('marker', 'before', tagid(id))
+ end
+ self
+ end
+ def marker_delete(*ids)
+ tk_send('marker', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def marker_exist?(id)
+ bool(tk_send('marker', 'exists', tagid(id)))
+ end
+ def marker_names(*pats)
+ simplelist(tk_send('marker', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|id|
+ Tk::BLT::PlotComponent::Marker.id2obj(self, id)
+ }
+ end
+ def marker_type(id)
+ tk_send('marker', 'type', tagid(id))
+ end
+
+ ###################
+
+ def xaxis_cget_tkstring(option)
+ itemcget_tkstring('xaxis', option)
+ end
+ def xaxis_cget(option)
+ itemcget('xaxis', option)
+ end
+ def xaxis_cget_strict(option)
+ itemcget_strict('xaxis', option)
+ end
+ def xaxis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('xaxis', slot, value)
+ end
+ def xaxis_configinfo(slot=nil)
+ itemconfiginfo('xaxis', slot)
+ end
+ def current_xaxis_configinfo(slot=nil)
+ current_itemconfiginfo('xaxis', slot)
+ end
+ def xaxis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'xaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def xaxis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'xaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def xaxis_bind_remove(context)
+ _bind_remove([path, 'xaxis', 'bind'], context)
+ self
+ end
+ def xaxis_bindinfo(context=nil)
+ _bindinfo([path, 'xaxis', 'bind'], context)
+ end
+ def xaxis_invtransform(val)
+ list(tk_send('xaxis', 'invtransform', val))
+ end
+ def xaxis_limits
+ list(tk_send('xaxis', 'limits'))
+ end
+ def xaxis_transform(val)
+ list(tk_send('xaxis', 'transform', val))
+ end
+ def xaxis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('xaxis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('xaxis', 'use'))
+ end
+ end
+
+ def x2axis_cget_tkstring(option)
+ itemcget_tkstring('x2axis', option)
+ end
+ def x2axis_cget(option)
+ itemcget('x2axis', option)
+ end
+ def x2axis_cget_strict(option)
+ itemcget_strict('x2axis', option)
+ end
+ def x2axis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('x2axis', slot, value)
+ end
+ def x2axis_configinfo(slot=nil)
+ itemconfiginfo('x2axis', slot)
+ end
+ def current_x2axis_configinfo(slot=nil)
+ current_itemconfiginfo('x2axis', slot)
+ end
+ def x2axis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'x2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def x2axis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'x2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def x2axis_bind_remove(context)
+ _bind_remove([path, 'x2axis', 'bind'], context)
+ self
+ end
+ def x2axis_bindinfo(context=nil)
+ _bindinfo([path, 'x2axis', 'bind'], context)
+ end
+ def x2axis_invtransform(val)
+ list(tk_send('x2axis', 'invtransform', val))
+ end
+ def x2axis_limits
+ list(tk_send('x2axis', 'limits'))
+ end
+ def x2axis_transform(val)
+ list(tk_send('x2axis', 'transform', val))
+ end
+ def x2axis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('x2axis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('x2axis', 'use'))
+ end
+ end
+
+ def yaxis_cget_tkstring(option)
+ itemcget_tkstring('yaxis', option)
+ end
+ def yaxis_cget(option)
+ itemcget('yaxis', option)
+ end
+ def yaxis_cget_strict(option)
+ itemcget_strict('yaxis', option)
+ end
+ def yaxis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('yaxis', slot, value)
+ end
+ def yaxis_configinfo(slot=nil)
+ itemconfiginfo('yaxis', slot)
+ end
+ def current_yaxis_configinfo(slot=nil)
+ current_itemconfiginfo('yaxis', slot)
+ end
+ def yaxis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'yaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def yaxis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'yaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def yaxis_bind_remove(context)
+ _bind_remove([path, 'yaxis', 'bind'], context)
+ self
+ end
+ def yaxis_bindinfo(context=nil)
+ _bindinfo([path, 'yaxis', 'bind'], context)
+ end
+ def yaxis_invtransform(val)
+ list(tk_send('yaxis', 'invtransform', val))
+ end
+ def yaxis_limits
+ list(tk_send('yaxis', 'limits'))
+ end
+ def yaxis_transform(val)
+ list(tk_send('yaxis', 'transform', val))
+ end
+ def yaxis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('yaxis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('yaxis', 'use'))
+ end
+ end
+
+ def y2axis_cget_tkstring(option)
+ itemcget_tkstring('y2axis', option)
+ end
+ def y2axis_cget(option)
+ itemcget('y2axis', option)
+ end
+ def y2axis_cget_strict(option)
+ itemcget_strict('y2axis', option)
+ end
+ def y2axis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('y2axis', slot, value)
+ end
+ def y2axis_configinfo(slot=nil)
+ axis_configinfo('y2axis', slot)
+ end
+ def current_y2axis_configinfo(slot=nil)
+ current_itemconfiginfo('y2axis', slot)
+ end
+ def y2axis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'y2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def y2axis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'y2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def y2axis_bind_remove(context)
+ _bind_remove([path, 'y2axis', 'bind'], context)
+ self
+ end
+ def y2axis_bindinfo(context=nil)
+ _bindinfo([path, 'y2axis', 'bind'], context)
+ end
+ def y2axis_invtransform(val)
+ list(tk_send('y2axis', 'invtransform', val))
+ end
+ def y2axis_limits
+ list(tk_send('y2axis', 'limits'))
+ end
+ def y2axis_transform(val)
+ list(tk_send('y2axis', 'transform', val))
+ end
+ def y2axis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('y2axis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('y2axis', 'use'))
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/container.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/container.rb
new file mode 100644
index 0000000..be05828
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/container.rb
@@ -0,0 +1,28 @@
+#
+# tkextlib/blt/container.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Container < TkWindow
+ TkCommandNames = ['::blt::container'.freeze].freeze
+ WidgetClassName = 'Container'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'name'
+ end
+ private :__strval_optkeys
+
+ def find_command(pat)
+ Hash[*simplelist(tk_send_without_enc('find', '-command', pat))]
+ end
+
+ def find_name(pat)
+ Hash[*simplelist(tk_send_without_enc('find', '-name', pat))]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb
new file mode 100644
index 0000000..1cc39df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb
@@ -0,0 +1,23 @@
+#
+# tkextlib/blt/cutbuffer.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module CutBuffer
+ TkCommandNames = ['::blt::cutbuffer'.freeze].freeze
+
+ def self.get(num = 0)
+ Tk.tk_call('::blt::cutbuffer', 'get', num)
+ end
+ def self.rotate(count = 1)
+ Tk.tk_call('::blt::cutbuffer', 'rotate', count)
+ end
+ def self.set(val, num = 0)
+ Tk.tk_call('::blt::cutbuffer', 'set', val, num)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb
new file mode 100644
index 0000000..aa5c565
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb
@@ -0,0 +1,269 @@
+#
+# tkextlib/blt/dragdrop.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module DragDrop
+ extend TkCore
+
+ TkCommandNames = ['::blt::drag&drop'.freeze].freeze
+
+ class Token < TkWindow
+ WidgetClassName = 'DragDropToken'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def initialize(arg)
+ if arg.kind_of?(Hash) # arg is a hash includes the widgetpath of token
+ arg = _symbolkey2str(arg)
+ install_win(nil, arg['widgetname'])
+ else # arg is a drag&drop source
+ tk_call('::blt::drag&drop', 'source', arg)
+ install_win(nil, tk_call('::blt::drag&drop', 'token', arg))
+ end
+ end
+ end
+
+ ###################################
+
+ extend TkItemConfigMethod
+ extend Tk::ValidateConfigure
+
+ class << self
+ def __item_config_cmd(id) # id := ['source'|'target', win]
+ ['::blt::drag&drop', id[0], id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'selftarget'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ super(id) << 'send'
+ end
+ private :__item_listval_optkeys
+
+ def __item_strval_optkeys(id)
+ super(id) << 'rejectbg' << 'rejectfg' << 'tokenbg'
+ end
+ private :__item_strval_optkeys
+
+ undef itemcget
+ undef itemcget_tkstring
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def source_configure(win, slot, value=None)
+ itemconfigure(['source', win], slot, value)
+ end
+ def source_configinfo(win, slot=nil)
+ itemconfiginfo(['source', win], slot)
+ end
+ def current_source_configinfo(win, slot=nil)
+ current_itemconfiginfo(['source', win], slot)
+ end
+ end
+
+ class PackageCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?t, ?w, :token ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['packagecmd']
+ end
+ end
+
+ class SiteCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?s, ?b, :compatible ],
+ [ ?t, ?w, :token ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?b, TkComm.method(:bool) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['sitecmd']
+ end
+ end
+
+ def self.__validation_class_list
+ super() << PackageCommand << SiteCommand
+ end
+
+ class << self
+ Tk::ValidateConfigure.__def_validcmd(binding, PackageCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, SiteCommand)
+ end
+
+ ###################################
+
+ class DnD_Handle < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?i, ?s, :ip_name ],
+ [ ?v, ?v, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?i, TkComm.method(:string) ],
+ [ ?v, TkComm.method(:tk_tcl2ruby) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+ end
+
+ def self.source_handler(win, datatype, cmd=Proc.new, *args)
+ _bind_for_event_class(DnD_Handle,
+ ['::blt::drag&drop', 'source', win, 'handler'],
+ cmd, *args)
+ end
+
+ def self.target_handler(win, datatype, cmd=Proc.new, *args)
+ _bind_for_event_class(DnD_Handle,
+ ['::blt::drag&drop', 'target', win, 'handler'],
+ cmd, *args)
+ end
+
+ ###################################
+
+ def self.init_source(win)
+ tk_call('::blt::drag&drop', 'source', win)
+ end
+
+ def self.source()
+ list(tk_call('::blt::drag&drop', 'source'))
+ end
+
+ def self.source_handler_list(win)
+ simplelist(tk_call('::blt::drag&drop', 'source', win, 'handler'))
+ end
+ def self.source_handler_info(win, type)
+ tk_tcl2ruby(tk_call('::blt::drag&drop', 'source', win, 'handler', type))
+ end
+
+ def self.target
+ list(tk_call('::blt::drag&drop', 'target'))
+ end
+ def self.target_handler_list(win)
+ simplelist(tk_call('::blt::drag&drop', 'target', win, 'handler'))
+ end
+
+ def self.handle_target(win, type, val=None)
+ tk_call('::blt::drag&drop', 'target', win, 'handle', type, val)
+ end
+
+ def self.token(win)
+ window(tk_call('::blt::drag&drop', 'token', win))
+ end
+
+ def self.drag(win, x, y)
+ tk_call('::blt::drag&drop', 'drag', win, x, y)
+ end
+ def self.drop(win, x, y)
+ tk_call('::blt::drag&drop', 'drop', win, x, y)
+ end
+
+ def self.errors(cmd=Proc.new)
+ tk_call('::blt::drag&drop', 'errors', cmd)
+ end
+
+ def self.active
+ bool(tk_call('::blt::drag&drop', 'active'))
+ end
+
+ def self.location(x=None, y=None)
+ list(tk_call('::blt::drag&drop', 'location', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb
new file mode 100644
index 0000000..0dba87a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb
@@ -0,0 +1,32 @@
+#
+# tkextlib/blt/eps.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class EPS < TkcItem
+ CItemTypeName = 'eps'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+end
+
+class Tk::Canvas
+ alias __BLT_EPS_item_strval_optkeys __item_strval_optkeys
+ def __item_strval_optkeys(id)
+ __BLT_EPS_item_strval_optkeys(id) + [
+ 'shadowcolor', 'title', 'titlecolor'
+ ]
+ end
+ private :__item_strval_optkeys
+
+ alias __BLT_EPS_item_boolval_optkeys __item_boolval_optkeys
+ def __item_boolval_optkeys(id)
+ __BLT_EPS_item_boolval_optkeys(id) + ['showimage']
+ end
+ private :__item_boolval_optkeys
+end
+
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb
new file mode 100644
index 0000000..6bd4424
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb
@@ -0,0 +1,67 @@
+#
+# tkextlib/blt/graph.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/component.rb'
+
+module Tk::BLT
+ class Graph < TkWindow
+ TkCommandNames = ['::blt::graph'.freeze].freeze
+ WidgetClassName = 'Graph'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include PlotComponent
+ include GraphCommand
+
+ def __boolval_optkeys
+ ['bufferelements', 'invertxy']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ ['text', 'label', 'title', 'file', 'plotbackground']
+ end
+ private :__strval_optkeys
+
+=begin
+ BarElement_ID = ['blt_graph_bar'.freeze, TkUtil.untrust('00000')].freeze
+
+ def bar(elem=nil, keys={})
+ if elem.kind_of?(Hash)
+ keys = elem
+ elem = nil
+ end
+ unless elem
+ elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
+ BarElement_ID[1].succ!
+ end
+ tk_send('bar', elem, keys)
+ Element.new(self, elem, :without_creating=>true)
+ end
+=end
+
+ def extents(item)
+ num_or_str(tk_send_without_enc('extents', item))
+ end
+
+ def invtransform(x, y)
+ list(tk_send_without_enc('invtransform', x, y))
+ end
+
+ def inside(x, y)
+ bool(tk_send_without_enc('inside', x, y))
+ end
+
+ def snap(output, keys={})
+ tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
+ self
+ end
+
+ def transform(x, y)
+ list(tk_send_without_enc('transform', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb
new file mode 100644
index 0000000..878bd99
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb
@@ -0,0 +1,112 @@
+#
+# tkextlib/blt/htext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig.rb'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Htext<TkWindow
+ Htext_Var = TkVarAccess.new_hash('htext')
+ Htext_Widget = TkVarAccess.new('htext(widget)', :window)
+ Htext_File = TkVarAccess.new('htext(file)')
+ Htext_Line = TkVarAccess.new('htext(line)')
+
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['::blt::htext'.freeze].freeze
+ WidgetClassName = 'Htext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ alias window_cget_tkstring itemcget_tkstring
+ alias window_cget itemcget
+ alias window_cget_strict itemcget_strict
+ alias window_configure itemconfigure
+ alias window_configuinfo itemconfiginfo
+ alias current_window_configuinfo current_itemconfiginfo
+
+ def __strval_optkeys
+ super() << 'filename'
+ end
+ private :__strval_optkeys
+
+ def append(win, keys={})
+ tk_send('append', _epath(win), keys)
+ self
+ end
+
+ def goto_line(idx)
+ tk_send_without_enc('gotoline', idx)
+ self
+ end
+ def current_line
+ number(tk_send_without_enc('gotoline'))
+ end
+
+ def index(str)
+ number(tk_send('index', str))
+ end
+
+ def line_pos(str)
+ tk_send('linepos', str)
+ end
+
+ def range(from=None, to=None)
+ tk_send_without_enc('range', from, to)
+ end
+
+ def scan_mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+
+ def scan_dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+
+ def search(pat, from=None, to=None)
+ num = number(tk_send('search', pat, from, to))
+ (num < 0)? nil: num
+ end
+
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear()
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_line(index)
+ tk_send_without_enc('selection', 'line', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(first, last)
+ tk_send_without_enc('selection', 'range', first, last)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+ def selection_word(index)
+ tk_send_without_enc('selection', 'word', index)
+ self
+ end
+
+ def windows(pat=None)
+ list(tk_send('windows', pat))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb
new file mode 100644
index 0000000..9f75a0b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb
@@ -0,0 +1,23 @@
+#
+# tkextlib/blt/spline.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Spline
+ extend TkCore
+
+ TkCommandNames = ['::blt::spline'.freeze].freeze
+
+ def self.natural(x, y, sx, sy)
+ tk_call('::blt::spline', 'natural', x, y, sx, sy)
+ end
+
+ def self.quadratic(x, y, sx, sy)
+ tk_call('::blt::spline', 'quadratic', x, y, sx, sy)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb
new file mode 100644
index 0000000..74093f1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb
@@ -0,0 +1,74 @@
+#
+# tkextlib/blt/stripchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/component.rb'
+
+module Tk::BLT
+ class Stripchart < TkWindow
+ TkCommandNames = ['::blt::stripchart'.freeze].freeze
+ WidgetClassName = 'Stripchart'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include PlotComponent
+ include GraphCommand
+
+ def __boolval_optkeys
+ ['bufferelements', 'buffergraph', 'invertxy']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ ['text', 'label', 'title', 'file',
+ 'background', 'plotbackground']
+ end
+ private :__strval_optkeys
+
+=begin
+ BarElement_ID = ['blt_stripchart_bar'.freeze, TkUtil.untrust('00000')].freeze
+
+ def bar(elem=nil, keys={})
+ if elem.kind_of?(Hash)
+ keys = elem
+ elem = nil
+ end
+ unless elem
+ elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
+ BarElement_ID[1].succ!
+ end
+ tk_send('bar', elem, keys)
+ Element.new(self, elem, :without_creating=>true)
+ end
+=end
+
+ def extents(item)
+ num_or_str(tk_send_without_enc('extents', item))
+ end
+
+ def invtransform(x, y)
+ list(tk_send_without_enc('invtransform', x, y))
+ end
+
+ def inside(x, y)
+ bool(tk_send_without_enc('inside', x, y))
+ end
+
+ def metafile(file=None)
+ # Windows only
+ tk_send('metafile', file)
+ self
+ end
+
+ def snap(output, keys={})
+ tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
+ self
+ end
+
+ def transform(x, y)
+ list(tk_send_without_enc('transform', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/table.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/table.rb
new file mode 100644
index 0000000..205e29e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/table.rb
@@ -0,0 +1,412 @@
+#
+# tkextlib/blt/table.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig.rb'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Table
+ include Tk
+ extend Tk
+ extend TkItemConfigMethod
+
+ TkCommandNames = ['::blt::table'.freeze].freeze
+
+ module TableContainer
+ def blt_table_add(*args)
+ Tk::BLT::Table.add(self, *args)
+ self
+ end
+
+ def blt_table_arrange()
+ Tk::BLT::Table.arrange(self)
+ self
+ end
+
+ def blt_table_cget_tkstring(*args)
+ Tk::BLT::Table.cget_tkstring(self, *args)
+ end
+ def blt_table_cget(*args)
+ Tk::BLT::Table.cget(self, *args)
+ end
+ def blt_table_cget_strict(*args)
+ Tk::BLT::Table.cget_strict(self, *args)
+ end
+
+ def blt_table_configure(*args)
+ Tk::BLT::Table.configure(self, *args)
+ self
+ end
+
+ def blt_table_configinfo(*args)
+ Tk::BLT::Table.configinfo(self, *args)
+ end
+
+ def blt_table_current_configinfo(*args)
+ Tk::BLT::Table.current_configinfo(self, *args)
+ end
+
+ def blt_table_locate(x, y)
+ Tk::BLT::Table.locate(self, x, y)
+ end
+
+ def blt_table_delete(*args)
+ Tk::BLT::Table.delete(self, *args)
+ self
+ end
+
+ def blt_table_extents(item)
+ Tk::BLT::Table.extents(self, item)
+ end
+
+ def blt_table_insert(*args)
+ Tk::BLT::Table.insert(self, *args)
+ self
+ end
+
+ def blt_table_insert_before(*args)
+ Tk::BLT::Table.insert_before(self, *args)
+ self
+ end
+
+ def blt_table_insert_after(*args)
+ Tk::BLT::Table.insert_after(self, *args)
+ self
+ end
+
+ def blt_table_join(first, last)
+ Tk::BLT::Table.join(self, first, last)
+ self
+ end
+
+ def blt_table_save()
+ Tk::BLT::Table.save(self)
+ end
+
+ def blt_table_search(*args)
+ Tk::BLT::Table.search(self, *args)
+ end
+
+ def blt_table_split(*args)
+ Tk::BLT::Table.split(self, *args)
+ self
+ end
+
+ def blt_table_itemcget_tkstring(*args)
+ Tk::BLT::Table.itemcget_tkstring(self, *args)
+ end
+ def blt_table_itemcget(*args)
+ Tk::BLT::Table.itemcget(self, *args)
+ end
+ def blt_table_itemcget_strict(*args)
+ Tk::BLT::Table.itemcget_strict(self, *args)
+ end
+
+ def blt_table_itemconfigure(*args)
+ Tk::BLT::Table.itemconfigure(self, *args)
+ self
+ end
+
+ def blt_table_itemconfiginfo(*args)
+ Tk::BLT::Table.itemconfiginfo(self, *args)
+ end
+
+ def blt_table_current_itemconfiginfo(*args)
+ Tk::BLT::Table.current_itemconfiginfo(self, *args)
+ end
+
+ def blt_table_iteminfo(item)
+ Tk::BLT::Table.iteminfo(self, item)
+ end
+ end
+ end
+end
+
+
+############################################
+class << Tk::BLT::Table
+ def __item_cget_cmd(id) # id := [ container, item ]
+ win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
+ ['::blt::table', 'cget', win, id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ container, item, ... ]
+ container, *items = id
+ win = (container.kind_of?(TkWindow))? container.path: container.to_s
+ ['::blt::table', 'configure', win, *items]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
+ win + ';'
+ end
+ private :__item_pathname
+
+ alias __itemcget_tkstring itemcget_tkstring
+ alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
+ alias __itemconfigure itemconfigure
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+
+ private :__itemcget_tkstring, :__itemcget, :__itemcget_strict
+ private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
+
+ def __boolval_optkeys
+ super() << 'propagate'
+ end
+ private :__boolval_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(Array)
+ case tag[0]
+ when Integer
+ # [row, col]
+ tag.join(',')
+ when :c, :C, 'c', 'C', :r, :R, 'r', 'R'
+ # c0 or r1 or C*, and so on
+ tag.collect{|elem| elem.to_s}.join('')
+ else
+ tag
+ end
+ elsif tag.kind_of?(TkWindow)
+ _epath(tag)
+ else
+ tag
+ end
+ end
+
+ def tagid2obj(tagid)
+ tagid
+ end
+
+ ############################################
+
+ def cget_tkstring(container, option)
+ __itemcget_tkstring([container], option)
+ end
+ def cget(container, option)
+ __itemcget([container], option)
+ end
+ def cget_strict(container, option)
+ __itemcget_strict([container], option)
+ end
+
+ def configure(container, *args)
+ __itemconfigure([container], *args)
+ end
+
+ def configinfo(container, *args)
+ __itemconfiginfo([container], *args)
+ end
+
+ def current_configinfo(container, *args)
+ __current_itemconfiginfo([container], *args)
+ end
+
+ def itemcget_tkstring(container, item, option)
+ __itemcget_tkstring([container, tagid(item)], option)
+ end
+ def itemcget(container, item, option)
+ __itemcget([container, tagid(item)], option)
+ end
+ def itemcget_strict(container, item, option)
+ __itemcget_strict([container, tagid(item)], option)
+ end
+
+ def itemconfigure(container, *args)
+ if args[-1].kind_of?(Hash)
+ # container, item, item, ... , hash_optkeys
+ keys = args.pop
+ fail ArgumentError, 'no item is given' if args.empty?
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __itemconfigure(id, keys)
+ else
+ # container, item, item, ... , option, value
+ val = args.pop
+ opt = args.pop
+ fail ArgumentError, 'no item is given' if args.empty?
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __itemconfigure(id, opt, val)
+ end
+ container
+ end
+
+ def itemconfiginfo(container, *args)
+ slot = args[-1]
+ if slot.kind_of?(String) || slot.kind_of?(Symbol)
+ slot = slot.to_s
+ if slot[0] == ?. || slot =~ /^\d+,\d+$/ || slot =~ /^(c|C|r|R)(\*|\d+)/
+ # widget || row,col || Ci or Ri
+ slot = nil
+ else
+ # option
+ slot = args.pop
+ end
+ else
+ slot = nil
+ end
+
+ fail ArgumentError, 'no item is given' if args.empty?
+
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __itemconfiginfo(id, slot)
+ end
+
+ def current_itemconfiginfo(container, *args)
+ slot = args[-1]
+ if slot.kind_of?(String) || slot.kind_of?(Symbol)
+ slot = slot.to_s
+ if slot[0] == ?. || slot =~ /^\d+,\d+$/ || slot =~ /^(c|C|r|R)(\*|\d+)/
+ # widget || row,col || Ci or Ri
+ slot = nil
+ else
+ # option
+ slot = args.pop
+ end
+ else
+ slot = nil
+ end
+
+ fail ArgumentError, 'no item is given' if args.empty?
+
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __current_itemconfiginfo(id, slot)
+ end
+
+ def info(container)
+ ret = {}
+ inf = list(tk_call('::blt::table', 'info', container))
+ until inf.empty?
+ opt = inf.slice!(0..1)
+ ret[opt[1..-1]] = opt[1]
+ end
+ ret
+ end
+
+ def iteminfo(container, item)
+ inf = list(tk_call('::blt::table', 'info', container, tagid(item)).chomp)
+
+ ret = []
+ until inf.empty? || (inf[0].kind_of?(String) && inf[0] =~ /^-/)
+ ret << inf.shift
+ end
+
+ if inf.length > 1
+ keys = {}
+ while inf.length > 1
+ opt = inf.slice!(0..1)
+ keys[opt[0][1..-1]] = opt[1]
+ end
+ ret << keys
+ end
+
+ ret
+ end
+
+ ############################################
+
+ def create_container(container)
+ tk_call('::blt::table', container)
+ begin
+ class << container
+ include Tk::BLT::Table::TableContainer
+ end
+ rescue
+ warn('fail to include TableContainer methods (frozen object?)')
+ end
+ container
+ end
+
+ def add(container, *args)
+ if args.empty?
+ tk_call('::blt::table', container)
+ else
+ args = args.collect{|arg|
+ if arg.kind_of?(TkWindow)
+ _epath(arg)
+ elsif arg.kind_of?(Array) # index
+ arg.join(',')
+ else
+ arg
+ end
+ }
+ tk_call('::blt::table', container, *args)
+ end
+ container
+ end
+
+ def arrange(container)
+ tk_call('::blt::table', 'arrange', container)
+ container
+ end
+
+ def delete(container, *args)
+ tk_call('::blt::table', 'delete', container, *args)
+ end
+
+ def extents(container, item)
+ ret = []
+ inf = list(tk_call('::blt::table', 'extents', container, item))
+ ret << inf.slice!(0..4) until inf.empty?
+ ret
+ end
+
+ def forget(*wins)
+ wins = wins.collect{|win| _epath(win)}
+ tk_call('::blt::table', 'forget', *wins)
+ end
+
+ def insert(container, *args)
+ tk_call('::blt::table', 'insert', container, *args)
+ end
+
+ def insert_before(container, *args)
+ tk_call('::blt::table', 'insert', container, '-before', *args)
+ end
+
+ def insert_after(container, *args)
+ tk_call('::blt::table', 'insert', container, '-after', *args)
+ end
+
+ def join(container, first, last)
+ tk_call('::blt::table', 'join', container, first, last)
+ end
+
+ def locate(container, x, y)
+ tk_call('::blt::table', 'locate', container, x, y)
+ end
+
+ def containers(arg={})
+ list(tk_call('::blt::table', 'containers', *hash_kv(arg)))
+ end
+
+ def containers_pattern(pat)
+ list(tk_call('::blt::table', 'containers', '-pattern', pat))
+ end
+
+ def containers_slave(win)
+ list(tk_call('::blt::table', 'containers', '-slave', win))
+ end
+
+ def save(container)
+ tk_call('::blt::table', 'save', container)
+ end
+
+ def search(container, keys={})
+ list(tk_call('::blt::table', 'containers', *hash_kv(keys)))
+ end
+
+ def split(container, *args)
+ tk_call('::blt::table', 'split', container, *args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb
new file mode 100644
index 0000000..82936c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb
@@ -0,0 +1,110 @@
+#
+# tkextlib/blt/tabnotebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/tabset.rb'
+
+module Tk::BLT
+ class Tabnotebook < Tabset
+ TkCommandNames = ['::blt::tabnotebook'.freeze].freeze
+ WidgetClassName = 'Tabnotebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Tab < Tk::BLT::Tabset::Tab
+ def self.new(parent, pos=nil, name=nil, keys={})
+ if pos.kind_of?(Hash)
+ keys = pos
+ name = nil
+ pos = nil
+ end
+ if name.kind_of?(Hash)
+ keys = name
+ name = nil
+ end
+ obj = nil
+ TabID_TBL.mutex.synchronize{
+ if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
+ obj = TabID_TBL[parent.path][name]
+ if pos
+ if pos.to_s == 'end'
+ obj.move_after('end')
+ else
+ obj.move_before(pos)
+ end
+ end
+ obj.configure if keys && ! keys.empty?
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(parent, pos, name, keys)
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj
+ end
+
+ def initialize(parent, pos, name, keys)
+ @t = parent
+ @tpath = parent.path
+ if name
+ @path = @id = name
+ unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
+ if pos
+ idx = tk_call(@tpath, 'index', @id)
+ if pos.to_s == 'end'
+ tk_call(@tpath, 'move', idx, 'after', 'end')
+ else
+ tk_call(@tpath, 'move', idx, 'before', pos)
+ end
+ end
+ tk_call(@tpath, 'tab', 'configure', @id, keys)
+ else
+ fail ArgumentError, "can't find tab \"#{@id}\" in #{@t}"
+ end
+ else
+ pos = 'end' unless pos
+ @path = @id = tk_call(@tpath, 'insert', pos, keys)
+ end
+ end
+ end
+
+ #######################################
+
+ def get_tab(index)
+ if (idx = tk_send_without_enc('id', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabset::Tab.id2obj(self, idx)
+ end
+ end
+ alias get_id get_tab
+
+ def get_tabobj(index)
+ if (idx = tk_send_without_enc('id', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabnotebook::Tab.new(self, nil, idx)
+ end
+ end
+
+ alias index_name index
+
+ def insert(pos=nil, keys={})
+ if pos.kind_of?(Hash)
+ keys = pos
+ pos = nil
+ end
+ pos = 'end' if pos.nil?
+ Tk::BLT::Tabnotebook::Tab.new(self, nil,
+ tk_send('insert', tagindex(pos), keys))
+
+ end
+ undef :insert_tabs
+
+ undef :tab_pageheight, :tab_pagewidth
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb
new file mode 100644
index 0000000..c4716c7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb
@@ -0,0 +1,504 @@
+#
+# tkextlib/blt/tabset.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Tabset < TkWindow
+ class Tab < TkObject
+ include TkTreatItemFont
+
+ TabID_TBL = TkCore::INTERP.create_table
+
+ (TabsetTab_ID = ['blt_tabset_tab'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TabID_TBL.mutex.synchronize{ TabID_TBL.clear }
+ }
+
+ def self.id2obj(tabset, id)
+ tpath = tabset.path
+ TabID_TBL.mutex.synchronize{
+ if TabID_TBL[tpath]
+ TabID_TBL[tpath][id]? TabID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(parent, pos=nil, name=nil, keys={})
+ if pos.kind_of?(Hash)
+ keys = pos
+ name = nil
+ pos = nil
+ end
+ if name.kind_of?(Hash)
+ keys = name
+ name = nil
+ end
+ obj = nil
+ TabID_TBL.mutex.synchronize{
+ if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
+ obj = TabID_TBL[parent.path][name]
+ if pos
+ if pos.to_s == 'end'
+ obj.move_after('end')
+ else
+ obj.move_before(pos)
+ end
+ end
+ obj.configure if keys && ! keys.empty?
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(parent, pos, name, keys)
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj
+ end
+
+ def initialize(parent, pos, name, keys)
+ @t = parent
+ @tpath = parent.path
+ if name
+ @path = @id = name
+ unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
+ if pos
+ idx = tk_call(@tpath, 'index', '-name', @id)
+ if pos.to_s == 'end'
+ tk_call(@tpath, 'move', idx, 'after', 'end')
+ else
+ tk_call(@tpath, 'move', idx, 'before', pos)
+ end
+ end
+ tk_call(@tpath, 'tab', 'configure', @id, keys)
+ else
+ pos = 'end' unless pos
+ tk_call(@tpath, 'insert', pos, @id, keys)
+ end
+ else
+ pos = 'end' unless pos
+ TabsetTab_ID.mutex.synchronize{
+ @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
+ TabsetTab_ID[1].succ!
+ }
+ tk_call(@tpath, 'insert', pos, @id, keys)
+ end
+ end
+
+ #def bind(context, cmd=Proc.new, *args)
+ # @t.tab_bind(@id, context, cmd, *args)
+ # self
+ #end
+ def bind(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tab_bind(@id, context, cmd, *args)
+ self
+ end
+ #def bind_append(context, cmd=Proc.new, *args)
+ # @t.tab_bind_append(@id, context, cmd, *args)
+ # self
+ #end
+ def bind_append(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tab_bind_append(@id, context, cmd, *args)
+ self
+ end
+ def bind_remove(context)
+ @t.tab_bind_remove(@id, context)
+ self
+ end
+ def bindinfo(context=nil)
+ @t.tab_bindinfo(@id, context)
+ end
+
+ def cget_tkstring(*args)
+ @t.tab_cget_tkstring(@id, *args)
+ end
+ def cget(*args)
+ @t.tab_cget(@id, *args)
+ end
+ def cget_strict(*args)
+ @t.tab_cget_strict(@id, *args)
+ end
+ def configure(*args)
+ @t.tab_configure(@id, *args)
+ end
+ def configinfo(*args)
+ @t.tab_configinfo(@id, *args)
+ end
+ def current_configinfo(*args)
+ @t.current_tab_configinfo(@id, *args)
+ end
+
+ def delete()
+ @t.delete(@id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@tpath].delete(@id)
+ }
+ self
+ end
+
+ def get_name()
+ @id.dup
+ end
+
+ def focus()
+ @t.focus(self.index)
+ end
+
+ def index()
+ @t.index_name(@id)
+ end
+
+ def invoke()
+ @t.invoke(self.index)
+ end
+
+ def move_before(idx)
+ @t.move_before(self.index, idx)
+ end
+ def move_after(idx)
+ @t.move_after(self.index, idx)
+ end
+
+ def perforation_highlight(mode)
+ @t.perforation_highlight(self.index, mode)
+ end
+ def perforation_invoke()
+ @t.perforation_invoke(self.index)
+ end
+
+ def see()
+ @t.see(self.index)
+ end
+
+ def tearoff(name=None)
+ @t.tab_tearoff(self.index, *args)
+ end
+ end
+
+ ########################################
+
+ class NamedTab < Tab
+ def self.new(parent, name)
+ super(parent, nil, name, {})
+ end
+ end
+
+ ########################################
+
+ include X_Scrollable
+ include TkItemConfigMethod
+
+ TkCommandNames = ['::blt::tabset'.freeze].freeze
+ WidgetClassName = 'Tabset'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
+ Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
+ }
+ end
+
+ ########################################
+
+ def __boolval_optkeys
+ super() << 'samewidth' << 'tearoff'
+ end
+ private :__strval_optkeys
+
+ def __strval_optkeys
+ super() << 'tabbackground' << 'tabforeground'
+ end
+ private :__strval_optkeys
+
+ def __item_cget_cmd(id)
+ [self.path, 'tab', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tab', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(Tk::BLT::Tabset::Tab)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+
+ alias tab_cget_tkstring itemcget_tkstring
+ alias tab_cget itemcget
+ alias tab_cget_strict itemcget_strict
+ alias tab_configure itemconfigure
+ alias tab_configinfo itemconfiginfo
+ alias current_tab_configinfo current_itemconfiginfo
+
+ def __item_strval_optkeys(id)
+ super(id) << 'shadow'
+ end
+ private :__item_strval_optkeys
+
+ def tagid(tab)
+ if tab.kind_of?(Tk::BLT::Tabset::Tab)
+ tab.id
+ else
+ tab
+ end
+ end
+
+ def tagindex(tab)
+ if tab.kind_of?(Tk::BLT::Tabset::Tab)
+ tab.index
+ else
+ tab
+ end
+ end
+
+ ########################################
+
+ def activate(index)
+ tk_send('activate', tagindex(index))
+ self
+ end
+ alias highlight activate
+
+ #def tabbind(tag, context, cmd=Proc.new, *args)
+ # _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def tabbind(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+ #def tabbind_append(tag, context, cmd=Proc.new, *args)
+ # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def tabbind_append(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+ def tabbind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+ def tabbindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def delete(first, last=None)
+ tk_send('delete', tagindex(first), tagindex(last))
+ if first.kind_of?(Tk::BLT::Tabset::Tab)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(first.id)
+ }
+ end
+ # middle tabs of the range are unknown
+ if last.kind_of?(Tk::BLT::Tabset::Tab)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(last.id)
+ }
+ end
+ self
+ end
+
+ def focus(index)
+ tk_send('focus', tagindex(index))
+ self
+ end
+
+ def get_tab(index)
+ if (idx = tk_send_without_enc('get', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabset::Tab.id2obj(self, idx)
+ end
+ end
+ def get_tabobj(index)
+ if (idx = tk_send_without_enc('get', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabset::Tab.new(self, nil, name, {})
+ end
+ end
+
+ def index(str)
+ num_or_str(tk_send('index', str))
+ end
+ def index_name(tab)
+ num_or_str(tk_send('index', '-name', tagid(tab)))
+ end
+
+ def insert(pos, tab, keys={})
+ pos = 'end' if pos.nil?
+ Tk::BLT::Tabset::Tab.new(self, tagindex(pos), tagid(tab), keys)
+ end
+ def insert_tabs(pos, *tabs)
+ pos = 'end' if pos.nil?
+ if tabs[-1].kind_of?(Hash)
+ keys = tabs.pop
+ else
+ keys = {}
+ end
+ fail ArgumentError, 'no tabs is given' if tabs.empty?
+ tabs.map!{|tab| tagid(tab)}
+ tk_send('insert', tagindex(pos), *(tabs + [keys]))
+ tabs.collect{|tab| Tk::BLT::Tabset::Tab.new(self, nil, tagid(tab))}
+ end
+
+ def invoke(index)
+ tk_send('invoke', tagindex(index))
+ end
+
+ def move_before(index, base_idx)
+ tk_send('move', tagindex(index), 'before', tagindex(base_idx))
+ self
+ end
+ def move_after(index, base_idx)
+ tk_send('move', tagindex(index), 'after', tagindex(base_idx))
+ self
+ end
+
+ def nearest(x, y)
+ Tk::BLT::Tabset::Tab.id2obj(self, num_or_str(tk_send_without_enc('nearest', x, y)))
+ end
+
+ def perforation_activate(mode)
+ tk_send('perforation', 'activate', mode)
+ self
+ end
+ def perforation_highlight(index, *args)
+ if args.empty?
+ # index --> mode
+ tk_send('perforation', 'highlight', index)
+ elsif args.size == 1
+ # args[0] --> mode
+ tk_send('perforation', 'highlight', tagindex(index), args[0])
+ else # Error: call to get Tcl's error message
+ tk_send('perforation', 'highlight', tagindex(index), *args)
+ end
+ self
+ end
+ def perforation_invoke(index=nil)
+ if index
+ tk_send('perforation', 'invoke', tagindex(index))
+ else
+ tk_send('perforation', 'invoke')
+ end
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(index)
+ tk_send('see', tagindex(index))
+ self
+ end
+
+ def size()
+ number(tk_send_without_enc('size'))
+ end
+
+ def select(index)
+ tk_send('select', tagindex(index))
+ self
+ end
+
+ def tab_dockall
+ tk_send('tab', 'dockall')
+ self
+ end
+
+ def tab_names(pat=None)
+ simplelist(tk_send('tab', 'names', pat)).collect{|name|
+ Tk::BLT::Tabset::Tab.id2obj(self, name)
+ }
+ end
+
+ def tab_objs(pat=None)
+ simplelist(tk_send('tab', 'names', pat)).collect{|name|
+ Tk::BLT::Tabset::Tab.new(self, nil, name, {})
+ }
+ end
+
+ def tab_ids(pat=None)
+ simplelist(tk_send('tab', 'names', pat))
+ end
+
+ def tab_pageheight
+ number(tk_send('tab', 'pageheight'))
+ end
+
+ def tab_pagewidth
+ number(tk_send('tab', 'pagewidth'))
+ end
+
+ def tab_tearoff(index, parent=None)
+ window(tk_send('tab', 'tearoff', tagindex(index), parent))
+ end
+
+ def xscrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias scrollcommand xscrollcommand
+
+ def xview(*index)
+ if index.empty?
+ list(tk_send_without_enc('view'))
+ else
+ tk_send_without_enc('view', *index)
+ self
+ end
+ end
+ alias view xview
+ alias view_moveto xview_moveto
+ alias view_scroll xview_scroll
+
+ alias scrollbar xscrollbar
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb
new file mode 100644
index 0000000..53ab9ac
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/blt/ted.rb
+#
+# *** This is alpha version, because there is no document on BLT. ***
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Ted
+ extend TkCore
+
+ TkCommandNames = ['::blt::ted'.freeze].freeze
+
+ ##############################
+
+ extend TkItemConfigMethod
+
+ class << self
+ def __item_cget_cmd(id)
+ ['::blt::ted', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ ['::blt::ted', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def cget_tkstring(master, option)
+ itemcget_tkstring(master, option)
+ end
+ def cget(master, option)
+ itemcget(master, option)
+ end
+ def cget_strict(master, option)
+ itemcget_strict(master, option)
+ end
+ def configure(master, slot, value=None)
+ itemconfigure(master, slot, value)
+ end
+ def configinfo(master, slot=nil)
+ itemconfiginfo(master, slot)
+ end
+ def current_configinfo(master, slot=nil)
+ current_itemconfiginfo(master, slot)
+ end
+ end
+
+ ##############################
+
+ def self.edit(master, *args)
+ tk_call('::blt::ted', 'edit', master, *args)
+ end
+ def self.rep(master, *args)
+ tk_call('::blt::ted', 'rep', master, *args)
+ end
+ def self.select(master, *args)
+ tk_call('::blt::ted', 'select', master, *args)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb
new file mode 100644
index 0000000..c67cafd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb
@@ -0,0 +1,25 @@
+#
+# tkextlib/blt/tile.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Tile
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+ # Require autoload-symbols which is a same name as widget classname.
+ # Those are used at TkComm._genobj_for_tkwidget method.
+
+ autoload :Button, 'tkextlib/blt/tile/button.rb'
+ autoload :CheckButton, 'tkextlib/blt/tile/checkbutton.rb'
+ autoload :Checkbutton, 'tkextlib/blt/tile/checkbutton.rb'
+ autoload :Radiobutton, 'tkextlib/blt/tile/radiobutton.rb'
+ autoload :RadioButton, 'tkextlib/blt/tile/radiobutton.rb'
+ autoload :Frame, 'tkextlib/blt/tile/frame.rb'
+ autoload :Label, 'tkextlib/blt/tile/label.rb'
+ autoload :Scrollbar, 'tkextlib/blt/tile/scrollbar.rb'
+ autoload :Toplevel, 'tkextlib/blt/tile/toplevel.rb'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb
new file mode 100644
index 0000000..2e0863c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/button.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/button'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Button < Tk::Button
+ TkCommandNames = ['::blt::tile::button'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
new file mode 100644
index 0000000..da230b5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
@@ -0,0 +1,17 @@
+#
+# tkextlib/blt/tile/checkbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/checkbutton'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class CheckButton < Tk::CheckButton
+ TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze
+ end
+ Checkbutton = CheckButton
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb
new file mode 100644
index 0000000..5434af4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/frame.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Frame < Tk::Frame
+ TkCommandNames = ['::blt::tile::frame'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb
new file mode 100644
index 0000000..f370c14
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/label.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/label'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Label < Tk::Label
+ TkCommandNames = ['::blt::tile::label'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
new file mode 100644
index 0000000..814f9a5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
@@ -0,0 +1,17 @@
+#
+# tkextlib/blt/tile/radiobutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/radiobutton'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class RadioButton < Tk::RadioButton
+ TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze
+ end
+ Radiobutton = RadioButton
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
new file mode 100644
index 0000000..2ae871d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/scrollbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/scrollbar'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Scrollbar < Tk::Scrollbar
+ TkCommandNames = ['::blt::tile::scrollbar'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
new file mode 100644
index 0000000..76d5f86
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/toplevel.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/toplevel'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Toplevel < Tk::Toplevel
+ TkCommandNames = ['::blt::tile::toplevel'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb
new file mode 100644
index 0000000..1a3563e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb
@@ -0,0 +1,1058 @@
+#
+# tkextlib/blt/tree.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Tree < TkObject
+ TkCommandNames = ['::blt::tree'.freeze].freeze
+
+ ###################################
+
+ class Node < TkObject
+ TreeNodeID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeNodeID_TBL.mutex.synchronize{
+ if TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, nil, 'node'=>Integer(id))
+ id = Integer(id)
+ if bool(tk_call(@tpath, 'exists', id))
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = tpath
+ @path = @id = id
+ TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
+ TreeNodeID_TBL[@tpath][@id] = self
+ }
+ obj
+ else
+ id
+ end
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(tree, parent, keys={})
+ keys = _symbolkey2str(keys)
+ tpath = tree.path
+
+ TreeNodeID_TBL.mutex.synchronize{
+ TreeNodeID_TBL[tpath] ||= {}
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, parent, keys) if parent
+ return obj
+ end
+
+ (obj = self.allocate).instance_eval{
+ initialize(tree, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
+ end
+
+ def initialize(tree, parent, keys={})
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if (id = keys['node']) && bool(tk_call(@tpath, 'exists', id))
+ @path = @id = id
+ keys.delete('node')
+ tk_call(@tpath, 'move', @id, parent, keys) if parent
+ else
+ parent = tk_call(@tpath, 'root') unless parent
+ @path = @id = tk_call(@tpath, 'insert', parent, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def apply(keys={})
+ @tree.apply(@id, keys)
+ self
+ end
+
+ def children()
+ @tree.children(@id)
+ end
+
+ def copy(parent, keys={})
+ @tree.copy(@id, parent, keys)
+ end
+ def copy_to(dest_tree, parent, keys={})
+ @tree.copy_to(@id, dest_tree, parent, keys)
+ end
+
+ def degree()
+ @tree.degree(@id)
+ end
+
+ def delete()
+ @tree.delete(@id)
+ self
+ end
+
+ def depth()
+ @tree.depth(@id)
+ end
+
+ def dump()
+ @tree.dump(@id)
+ end
+
+ def dump_to_file(file)
+ @tree.dump_to_file(@id, file)
+ self
+ end
+
+ def exist?(keys={})
+ @tree.exist?(@id, keys)
+ end
+
+ def find(keys={})
+ @tree.find(@id, keys)
+ end
+
+ def find_child(label)
+ @tree.find_child(@id, label)
+ end
+
+ def first_child()
+ @tree.first_child(@id)
+ end
+
+ def get()
+ @tree.get(@id)
+ end
+ def get_value(key, default_val=None)
+ @tree.get_value(@id, key, default_val)
+ end
+
+ def index()
+ @tree.index(@id)
+ end
+
+ def leaf?()
+ @tree.leaf?(@id)
+ end
+ def link?()
+ @tree.link?(@id)
+ end
+ def root?()
+ @tree.root?(@id)
+ end
+
+ def keys()
+ @tree.keys(@id)
+ end
+
+ def label(text = nil)
+ @tree.label(@id, nil)
+ end
+ def label=(text)
+ @tree.label(@id, text)
+ end
+
+ def last_child()
+ @tree.last_child(@id)
+ end
+
+ def move(dest, keys={})
+ @tree.keys(@id, dest, keys)
+ self
+ end
+
+ def next()
+ @tree.next(@id)
+ end
+
+ def next_sibling()
+ @tree.next_sibling(@id)
+ end
+
+ def parent()
+ @tree.parent(@id)
+ end
+
+ def fullpath()
+ @tree.fullpath(@id)
+ end
+
+ def position()
+ @tree.position(@id)
+ end
+
+ def previous()
+ @tree.previous(@id)
+ end
+
+ def prev_sibling()
+ @tree.prev_sibling(@id)
+ end
+
+ def restore(str, keys={})
+ @tree.restore(@id, str, keys)
+ self
+ end
+ def restore_overwrite(str, keys={})
+ @tree.restore_overwrite(@id, str, keys)
+ self
+ end
+
+ def restore_from_file(file, keys={})
+ @tree.restore_from_file(@id, file, keys)
+ self
+ end
+ def restore_overwrite_from_file(file, keys={})
+ @tree.restore_overwrite_from_file(@id, file, keys)
+ self
+ end
+
+ def root()
+ @tree.root(@id)
+ self
+ end
+
+ def set(data)
+ @tree.set(@id, data)
+ self
+ end
+
+ def size()
+ @tree.size(@id)
+ end
+
+ def sort(keys={})
+ @tree.sort(@id, keys)
+ self
+ end
+
+ def type(key)
+ @tree.type(@id, key)
+ end
+
+ def unset(*keys)
+ @tree.unset(@id, *keys)
+ self
+ end
+
+ def values(key=None)
+ @tree.values(@id, key)
+ end
+ end
+
+ ###################################
+
+ class Tag < TkObject
+ TreeTagID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ (TreeTag_ID = ['blt_tree_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeTagID_TBL.mutex.synchronize{
+ if TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][id]
+ TreeTagID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, id)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id.dup.freeze if id
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(tree, tag_str = nil)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if tag_str
+ @path = @id = tag_str.dup.freeze
+ else
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
+ TreeTag_ID[1].succ!
+ }
+ end
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def id
+ @id
+ end
+
+ def add(*nodes)
+ tk_call(@tpath, 'tag', 'add', @id, *nodes)
+ self
+ end
+
+ def delete(*nodes)
+ tk_call(@tpath, 'tag', 'delete', @id, *nodes)
+ self
+ end
+
+ def forget()
+ tk_call(@tpath, 'tag', 'forget', @id)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath].delete(@id)
+ }
+ self
+ end
+
+ def nodes()
+ simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|node|
+ Tk::BLT::Tree::Node.id2obj(@path, node)
+ }
+ end
+
+ def set(node)
+ tk_call(@tpath, 'tag', 'set', node, @id)
+ self
+ end
+
+ def unset(node)
+ tk_call(@tpath, 'tag', 'unset', node, @id)
+ self
+ end
+ end
+
+ ###################################
+
+ class Notify < TkObject
+ NotifyID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ NotifyID_TBL.mutex.synchronize{ NotifyID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ NotifyID_TBL.mutex.synchronize{
+ if NotifyID_TBL[tpath]
+ if NotifyID_TBL[tpath][id]
+ NotifyID_TBL[tpath][id]
+ else
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ obj
+ end
+ else
+ return id
+ end
+ }
+ end
+
+ def self.new(tree, *args, &b)
+ NotifyID_TBL.mutex.synchronize{
+ if tree.kind_of?(Array)
+ # not create
+ tpath = tree[0].path
+ NotifyID_TBL[tpath] ||= {}
+ unless (obj = NotifyID_TBL[tpath][tree[1]])
+ (NotifyID_TBL[tpath][tree[1]] =
+ obj = self.allocate).instance_eval{
+ @parent = @tree = tree[0]
+ @tpath = @parent.path
+ @path = @id = tree[1]
+ }
+ end
+ return obj
+ end
+
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
+ end
+
+ def initialize(tree, *args, &b)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0])
+ cmd = args.shift
+ # elsif args[-1].kind_of?(Proc) || args[-1].kind_of?(Method)
+ elsif TkComm._callback_entry?(args[-1])
+ cmd = args.pop
+ elsif b
+ cmd = Proc.new(&b)
+ else
+ fail ArgumentError, "lack of 'command' argument"
+ end
+
+ args = args.collect{|arg| '-' << arg.to_s}
+
+ args << proc{|id, type|
+ cmd.call(Tk::BLT::Tree::Node.id2obj(@tree, id),
+ ((type[0] == ?-)? type[1..-1]: type))
+ }
+
+ @path = @id = tk_call(@tpath, 'notify', 'create', *args)
+ end
+
+ def id
+ @id
+ end
+
+ def delete()
+ tk_call(@tpath, 'notify', 'delete', @id)
+ NotifyID_TBL.mutex.synchronize{
+ NotifyID_TBL[@tpath].delete(@id)
+ }
+ self
+ end
+
+ def info()
+ lst = simplelist(tk_call(@tpath, 'notify', 'info', id))
+ lst[0] = Tk::BLT::Tree::Notify.id2obj(@tree, lst[0])
+ lst[1] = simplelist(lst[1]).collect{|flag| flag[1..-1]}
+ lst[2] = tk_tcl2ruby(lst[2])
+ lst
+ end
+ end
+
+ ###################################
+
+ class Trace < TkObject
+ TraceID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TraceID_TBL.mutex.synchronize{ TraceID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TraceID_TBL.mutex.synchronize{
+ if TraceID_TBL[tpath]
+ if TraceID_TBL[tpath][id]
+ TraceID_TBL[tpath][id]
+ else
+ begin
+ # self.new([tree, id])
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = node # == traceID
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ obj
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(tree, *args, &b)
+ TraceID_TBL.mutex.synchronize{
+ if tree.kind_of?(Array)
+ # not create
+ tpath = tree[0].path
+ TraceID_TBL[tpath] ||= {}
+ unless (obj = TraceID_TBL[tpath][tree[1]])
+ (TraceID_TBL[tpath][tree[1]] =
+ obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = tree[1] # == traceID
+ }
+ end
+ return obj
+ end
+
+ # super(true, tree, *args, &b)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
+ end
+
+ def initialize(tree, node, key, opts, cmd=nil, &b)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if !cmd
+ if b
+ cmd = Proc.new(&b)
+ else
+ fail ArgumentError, "lack of 'command' argument"
+ end
+ end
+
+ @path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
+ proc{|t, id, k, ops|
+ tobj = Tk::BLT::Tree.id2obj(t)
+ if tobj.kind_of?(Tk::BLT::Tree)
+ nobj = Tk::BLT::Tree::Node.id2obj(tobj, id)
+ else
+ nobj = id
+ end
+ cmd.call(tobj, nobj, k, ops)
+ })
+ end
+
+ def id
+ @id
+ end
+
+ def delete()
+ tk_call(@tpath, 'trace', 'delete', @id)
+ TraceID_TBL.mutex.synchronize{
+ TraceID_TBL[tpath].delete(@id)
+ }
+ self
+ end
+
+ def info()
+ lst = simplelist(tk_call(@tpath, 'trace', 'info', id))
+ lst[0] = Tk::BLT::Tree::Trace.id2obj(@tree, lst[0])
+ lst[2] = simplelist(lst[2])
+ lst[3] = tk_tcl2ruby(lst[3])
+ lst
+ end
+ end
+
+ ###################################
+
+ TreeID_TBL = TkCore::INTERP.create_table
+
+ (Tree_ID = ['blt_tree'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ def __keyonly_optkeys
+ {
+ # apply / find command
+ 'invert'=>nil, 'leafonly'=>nil, 'nocase'=>nil,
+
+ # apply / find / sort command
+ 'path'=>nil,
+
+ # copy / restore / restorefile command
+ 'overwrite'=>nil,
+
+ # copy command
+ 'recurse'=>nil, 'tags'=>nil,
+
+ # sort command
+ 'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil,
+ 'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil,
+ }
+ end
+
+ def self.id2obj(id)
+ TreeID_TBL.mutex.synchronize{
+ TreeID_TBL[id]? TreeID_TBL[id]: id
+ }
+ end
+
+ def self.names(pat = None)
+ simplelist(tk_call('::blt::tree', 'names', pat)).collect{|name|
+ id2obj(name)
+ }
+ end
+
+ def self.destroy(*names)
+ tk_call('::blt::tree', 'destroy',
+ *(names.collect{|n| (n.kind_of?(Tk::BLT::Tree))? n.id: n }) )
+ end
+
+ def self.new(name = nil)
+ TreeID_TBL.mutex.synchronize{
+ if name && TreeID_TBL[name]
+ TreeID_TBL[name]
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(name)
+ TreeID_TBL[@id] = self
+ }
+ obj
+ end
+ }
+ end
+
+ def initialzie(name = nil)
+ if name
+ @path = @id = name
+ else
+ Tree_ID.mutex.synchronize{
+ @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
+ Tree_ID[1].succ!
+ }
+ end
+
+ tk_call('::blt::tree', 'create', @id)
+ end
+
+ def __destroy_hook__
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
+ }
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BLT::Tree::Node) ||
+ tag.kind_of?(Tk::BLT::Tree::Tag) ||
+ tag.kind_of?(Tk::BLT::Tree::Notify) ||
+ tag.kind_of?(Tk::BLT::Tree::Trace)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+
+ def destroy()
+ tk_call('::blt::tree', 'destroy', @id)
+ self
+ end
+
+ def ancestor(node1, node2)
+ Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'ancestor',
+ tagid(node1), tagid(node2)))
+ end
+
+ def apply(node, keys={})
+ tk_call('::blt::tree', 'apply', tagid(node), __conv_keyonly_opts(keys))
+ self
+ end
+
+ def attach(tree_obj)
+ tk_call('::blt::tree', 'attach', tree_obj)
+ self
+ end
+
+ def children(node)
+ simplelist(tk_call('::blt::tree', 'children', tagid(node))).collect{|n|
+ Tk::BLT::Tree::Node.id2obj(self, n)
+ }
+ end
+
+ def copy(src, parent, keys={})
+ id = tk_call('::blt::tree', 'copy', tagid(src), tagid(parent),
+ __conv_keyonly_opts(keys))
+ Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
+ end
+ def copy_to(src, dest_tree, parent, keys={})
+ return copy(src, parent, keys={}) unless dest_tree
+
+ id = tk_call('::blt::tree', 'copy', tagid(src), dest_tree,
+ tagid(parent), __conv_keyonly_opts(keys))
+ Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id)
+ end
+
+ def degree(node)
+ number(tk_call('::blt::tree', 'degree', tagid(node)))
+ end
+
+ def delete(*nodes)
+ tk_call('::blt::tree', 'delete', *(nodes.collect{|node| tagid(node)}))
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
+ nodes.each{|node|
+ if node.kind_of?(Tk::BLT::Tree::Node)
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
+ else
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
+ end
+ }
+ }
+ self
+ end
+
+ def depth(node)
+ number(tk_call('::blt::tree', 'depth', tagid(node)))
+ end
+
+ def dump(node)
+ simplelist(tk_call('::blt::tree', 'dump', tagid(node))).collect{|n|
+ simplelist(n)
+ }
+ end
+
+ def dump_to_file(node, file)
+ tk_call('::blt::tree', 'dumpfile', tagid(node), file)
+ self
+ end
+
+ def exist?(node, key=None)
+ bool(tk_call('::blt::tree', 'exists', tagid(node), key))
+ end
+
+ def find(node, keys={})
+ simplelist(tk_call('::blt::tree', 'find', tagid(node),
+ __conv_keyonly_opts(keys))).collect{|n|
+ Tk::BLT::Tree::Node.id2obj(self, n)
+ }
+ end
+
+ def find_child(node, label)
+ ret = tk_call('::blt::tree', 'findchild', tagid(node), label)
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def first_child(node)
+ ret = tk_call('::blt::tree', 'firstchild', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def get(node)
+ Hash[*simplelist(tk_call('::blt::tree', 'get', tagid(node)))]
+ end
+ def get_value(node, key, default_val=None)
+ tk_call('::blt::tree', 'get', tagid(node), key, default_val)
+ end
+
+ def index(node)
+ Tk::BLT::Tree::Node.id2obj(self,
+ tk_call('::blt::tree', 'index', tagid(node)))
+ end
+
+ def insert(parent, keys={})
+ id = tk_call('::blt::tree', 'insert', tagid(parent), keys)
+ Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
+ end
+
+ def ancestor?(node1, node2)
+ bool(tk_call('::blt::tree', 'is', 'ancestor',
+ tagid(node1), tagid(node2)))
+ end
+ def before?(node1, node2)
+ bool(tk_call('::blt::tree', 'is', 'before',
+ tagid(node1), tagid(node2)))
+ end
+ def leaf?(node)
+ bool(tk_call('::blt::tree', 'is', 'leaf', tagid(node)))
+ end
+ def link?(node)
+ bool(tk_call('::blt::tree', 'is', 'link', tagid(node)))
+ end
+ def root?(node)
+ bool(tk_call('::blt::tree', 'is', 'root', tagid(node)))
+ end
+
+ def keys(node, *nodes)
+ if nodes.empty?
+ simplelist(tk_call('blt::tree', 'keys', tagid(node)))
+ else
+ simplelist(tk_call('blt::tree', 'keys', tagid(node),
+ *(nodes.collect{|n| tagid(n)}))).collect{|lst|
+ simplelist(lst)
+ }
+ end
+ end
+
+ def label(node, text=nil)
+ if text
+ tk_call('::blt::tree', 'label', tagid(node), text)
+ text
+ else
+ tk_call('::blt::tree', 'label', tagid(node))
+ end
+ end
+
+ def last_child(node)
+ ret = tk_call('::blt::tree', 'lastchild', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def link(parent, node, keys={})
+ ret = tk_call('::blt::tree', 'link', tagid(parent), tagid(node),
+ __conv_keyonly_opts(keys))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def move(node, dest, keys={})
+ tk_call('::blt::tree', 'move', tagid(node), tagid(dest), keys)
+ self
+ end
+
+ def next(node)
+ ret = tk_call('::blt::tree', 'next', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def next_sibling(node)
+ ret = tk_call('::blt::tree', 'nextsibling', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def notify_create(*args, &b)
+ Tk::BLT::Tree::Notify.new(self, *args, &b)
+ end
+
+ def notify_delete(id)
+ if id.kind_of?(Tk::BLT::Tree::Notify)
+ id.delete
+ else
+ tk_call(@path, 'notify', 'delete', id)
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
+ }
+ end
+ self
+ end
+
+ def notify_info(id)
+ lst = simplelist(tk_call(@path, 'notify', 'info', tagid(id)))
+ lst[0] = Tk::BLT::Tree::Notify.id2obj(self, lst[0])
+ lst[1] = simplelist(lst[1]).collect{|flag| flag[1..-1]}
+ lst[2] = tk_tcl2ruby(lst[2])
+ lst
+ end
+
+ def notify_names()
+ tk_call(@path, 'notify', 'names').collect{|id|
+ Tk::BLT::Tree::Notify.id2obj(self, id)
+ }
+ end
+
+ def parent(node)
+ ret = tk_call('::blt::tree', 'parent', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def fullpath(node)
+ tk_call('::blt::tree', 'path', tagid(node))
+ end
+
+ def position(node)
+ number(tk_call('::blt::tree', 'position', tagid(node)))
+ end
+
+ def previous(node)
+ ret = tk_call('::blt::tree', 'previous', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def prev_sibling(node)
+ ret = tk_call('::blt::tree', 'prevsibling', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def restore(node, str, keys={})
+ tk_call('::blt::tree', 'restore', tagid(node), str,
+ __conv_keyonly_opts(keys))
+ self
+ end
+ def restore_overwrite(node, str, keys={})
+ keys = __conv_keyonly_opts(keys)
+ keys.delete('overwrite')
+ keys.delete(:overwrite)
+ tk_call('::blt::tree', 'restore', tagid(node), str, '-overwrite', keys)
+ self
+ end
+
+ def restore_from_file(node, file, keys={})
+ tk_call('::blt::tree', 'restorefile', tagid(node), file,
+ __conv_keyonly_opts(keys))
+ self
+ end
+ def restore_overwrite_from_file(node, file, keys={})
+ keys = __conv_keyonly_opts(keys)
+ keys.delete('overwrite')
+ keys.delete(:overwrite)
+ tk_call('::blt::tree', 'restorefile', tagid(node), file,
+ '-overwrite', keys)
+ self
+ end
+
+ def root(node=None)
+ Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root',
+ tagid(node)))
+ end
+
+ def set(node, data)
+ unless data.kind_of?(Hash)
+ fail ArgumentError, 'Hash is expected for data'
+ end
+ args = []
+ data.each{|k, v| args << k << v}
+ tk_call('::blt::tree', 'set', tagid(node), *args)
+ self
+ end
+
+ def size(node)
+ number(tk_call('::blt::tree', 'size', tagid(node)))
+ end
+
+ def sort(node, keys={})
+ tk_call('::blt::tree', 'sort', tagid(node), __conv_keyonly_opts(keys))
+ self
+ end
+
+ def tag_add(tag, *nodes)
+ tk_call(@path, 'tag', 'add', tagid(tag), *(nodes.collect{|n| tagid(n)}))
+ self
+ end
+
+ def tag_delete(tag, *nodes)
+ tk_call(@path, 'tag', 'delete', tagid(tag),
+ *(nodes.collect{|n| tagid(n)}))
+ self
+ end
+
+ def tag_forget(tag)
+ tag = tag.id if tag.kind_of?(Tk::BLT::Tree::Tag)
+ tk_call(@path, 'tag', 'forget', tag)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@path].delete(tag)
+ }
+ self
+ end
+
+ def tag_get(node, *patterns)
+ simplelist(tk_call(@tpath, 'tag', 'get', tagid(node),
+ *(patterns.collect{|pat| tagid(pat)}))).collect{|str|
+ Tk::BLT::Tree::Tag.id2obj(self, str)
+ }
+ end
+
+ def tag_names(node = None)
+ simplelist(tk_call(@tpath, 'tag', 'names', tagid(node))).collect{|str|
+ Tk::BLT::Tree::Tag.id2obj(self, str)
+ }
+ end
+
+ def tag_nodes(tag)
+ simplelist(tk_call(@tpath, 'tag', 'nodes', tagid(tag))).collect{|node|
+ Tk::BLT::Tree::Node.id2obj(self, node)
+ }
+ end
+
+ def tag_set(node, *tags)
+ tk_call(@path, 'tag', 'set', tagid(node), *(tags.collect{|t| tagid(t)}))
+ self
+ end
+
+ def tag_unset(node, *tags)
+ tk_call(@path, 'tag', 'unset', tagid(node),
+ *(tags.collect{|t| tagid(t)}))
+ self
+ end
+
+ def trace_create(*args, &b)
+ Tk::BLT::Tree::Trace.new(self, *args, &b)
+ end
+
+=begin
+ def trace_delete(*args)
+ args.each{|id|
+ if id.kind_of?(Tk::BLT::Tree::Trace)
+ id.delete
+ else
+ tk_call(@path, 'trace', 'delete', id)
+ Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)
+ end
+ self
+ }
+ end
+=end
+ def trace_delete(*args)
+ args = args.collect{|id| tagid(id)}
+ tk_call(@path, 'trace', 'delete', *args)
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
+ }
+ self
+ end
+
+ def trace_info(id)
+ lst = simplelist(tk_call(@path, 'trace', 'info', tagid(id)))
+ lst[0] = Tk::BLT::Tree::Trace.id2obj(self, lst[0])
+ lst[2] = simplelist(lst[2])
+ lst[3] = tk_tcl2ruby(lst[3])
+ lst
+ end
+
+ def trace_names()
+ tk_call(@path, 'trace', 'names').collect{|id|
+ Tk::BLT::Tree::Trace.id2obj(self, id)
+ }
+ end
+
+ def type(node, key)
+ tk_call('::blt::tree', 'type', tagid(node), key)
+ end
+
+ def unset(node, *keys)
+ tk_call('::blt::tree', 'unset', tagid(node), *keys)
+ self
+ end
+
+ def values(node, key=None)
+ simplelist(tk_call('::blt::tree', 'values', tagid(node), key))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb
new file mode 100644
index 0000000..38d9041
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb
@@ -0,0 +1,1287 @@
+#
+# tkextlib/blt/treeview.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tk/validation.rb'
+
+module Tk::BLT
+ class Treeview < TkWindow
+ module ConfigMethod
+ end
+
+ module TagOrID_Methods
+ end
+
+ class Node < TkObject
+ end
+
+ class Tag < TkObject
+ end
+ end
+
+ class Hiertable < Treeview
+ end
+end
+
+######################################
+
+module Tk::BLT::Treeview::ConfigMethod
+ include TkItemConfigMethod
+
+ def __item_boolval_optkeys(id)
+ case id
+ when Array
+ # id := [ 'column', name ]
+ ['edit', 'hide']
+ when 'sort'
+ ['decreasing']
+ else
+ []
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ case id
+ when Array
+ # id := [ 'column', name ]
+ super() << 'titleforeground' << 'titleshadow'
+ when 'sort'
+ ['decreasing']
+ else
+ []
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ case id
+ when 'entry'
+ ['bindtags']
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_cget_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name ]
+ [self.path, id[0], 'cget', id[1]]
+ else
+ [self.path, id, 'cget']
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name ]
+ [self.path, id[0], 'configure', id[1]]
+ else
+ [self.path, id, 'configure']
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def column_cget_tkstring(name, option)
+ itemcget_tkstring(['column', name], option)
+ end
+ def column_cget(name, option)
+ itemcget(['column', name], option)
+ end
+ def column_cget_strict(name, option)
+ itemcget_strict(['column', name], option)
+ end
+ def column_configure(name, slot, value=None)
+ itemconfigure(['column', name], slot, value)
+ end
+ def column_configinfo(name, slot=nil)
+ itemconfiginfo(['column', name], slot)
+ end
+ def current_column_configinfo(name, slot=nil)
+ current_itemconfiginfo(['column', name], slot)
+ end
+
+ def button_cget_tkstring(option)
+ itemcget_tkstring('button', option)
+ end
+ def button_cget(option)
+ itemcget('button', option)
+ end
+ def button_cget_strict(option)
+ itemcget_strict('button', option)
+ end
+ def button_configure(slot, value=None)
+ itemconfigure('button', slot, value)
+ end
+ def button_configinfo(slot=nil)
+ itemconfiginfo('button', slot)
+ end
+ def current_button_configinfo(slot=nil)
+ current_itemconfiginfo('button', slot)
+ end
+
+ def entry_cget_tkstring(option)
+ itemcget_tkstring('entry', option)
+ end
+ def entry_cget(option)
+ ret = itemcget('entry', option)
+ if option == 'bindtags' || option == :bindtags
+ ret.collect{|tag| TkBindTag.id2obj(tag)}
+ else
+ ret
+ end
+ end
+ def entry_cget_strict(option)
+ ret = itemcget_strict('entry', option)
+ if option == 'bindtags' || option == :bindtags
+ ret.collect{|tag| TkBindTag.id2obj(tag)}
+ else
+ ret
+ end
+ end
+ def entry_configure(slot, value=None)
+ itemconfigure('entry', slot, value)
+ end
+ def entry_configinfo(slot=nil)
+ ret = itemconfiginfo('entry', slot)
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ if slot == 'bindtags' || slot == :bindtags
+ ret[-2] = ret[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ ret[-1] = ret[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+ else
+ inf = ret.assoc('bindtags')
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = ret['bindtags'])
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ ret['bindtags'] = inf
+ end
+ end
+
+ ret
+ end
+ def current_entry_configinfo(slot=nil)
+ ret = current_itemconfiginfo('entry', slot)
+
+ if (val = ret['bindtags'])
+ ret['bindtags'] = val.collect{|tag| TkBindTag.id2obj(tag)}
+ end
+
+ ret
+ end
+
+ def sort_cget_tkstring(option)
+ itemcget_tkstring('sort', option)
+ end
+ def sort_cget(option)
+ itemcget('sort', option)
+ end
+ def sort_cget_strict(option)
+ itemcget_strict('sort', option)
+ end
+ def sort_configure(slot, value=None)
+ itemconfigure('sort', slot, value)
+ end
+ def sort_configinfo(slot=nil)
+ itemconfiginfo('sort', slot)
+ end
+ def current_sort_configinfo(slot=nil)
+ current_itemconfiginfo('sort', slot)
+ end
+
+ def text_cget_tkstring(option)
+ itemcget_tkstring('text', option)
+ end
+ def text_cget(option)
+ itemcget('text', option)
+ end
+ def text_cget_strict(option)
+ itemcget_strict('text', option)
+ end
+ def text_configure(slot, value=None)
+ itemconfigure('text', slot, value)
+ end
+ def text_configinfo(slot=nil)
+ itemconfiginfo('text', slot)
+ end
+ def current_text_configinfo(slot=nil)
+ current_itemconfiginfo('text', slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::BLT::Treeview
+ TkCommandNames = ['::blt::treeview'.freeze].freeze
+ WidgetClassName = 'TreeView'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include Scrollable
+ include ValidateConfigure
+ include ItemValidateConfigure
+ include Tk::BLT::Treeview::ConfigMethod
+
+ ########################
+
+ def __boolval_optkeys
+ ['autocreate', 'allowduplicates', 'exportselection', 'flat', 'hideroot',
+ 'newtags', 'showtitles', 'sortselection']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() + ['focusforeground', 'linecolor', 'separator', 'trim']
+ end
+ private :__strval_optkeys
+
+ ########################
+
+ class OpenCloseCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?W, ?w, :widget ],
+ [ ?p, ?s, :name ],
+ [ ?P, ?s, :fullpath ],
+ [ ?#, ?x, :node_id ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['opencommand', 'closecomand']
+ end
+ end
+
+ def __validation_class_list
+ super() << OpenCloseCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, OpenCloseCommand)
+
+ ########################
+
+ def __item_validation_class_list(id)
+ case id
+ when 'entry'
+ super(id) << OpenCloseCommand
+ else
+ super(id)
+ end
+ end
+
+ Tk::ItemValidateConfigure.__def_validcmd(binding, OpenCloseCommand)
+
+ ########################
+
+ def __destroy_hook__
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.mutex.synchronize{
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
+ }
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.mutex.synchronize{
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
+ }
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BLT::Treeview::Node) \
+ || tag.kind_of?(Tk::BLT::Treeview::Tag)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+ private :tagid
+
+ def tagid2obj(tagid)
+ if tagid.kind_of?(Integer)
+ Tk::BLT::Treeview::Node.id2obj(self, tagid.to_s)
+ elsif tagid.kind_of?(String)
+ if tagid =~ /^\d+$/
+ Tk::BLT::Treeview::Node.id2obj(self, tagid)
+ else
+ Tk::BLT::Treeview::Tag.id2obj(self, tagid)
+ end
+ else
+ tagid
+ end
+ end
+
+ def bbox(*tags)
+ list(tk_send('bbox', *(tags.collect{|tag| tagid(tag)})))
+ end
+
+ def screen_bbox(*tags)
+ list(tk_send('bbox', '-screen', *(tags.collect{|tag| tagid(tag)})))
+ end
+
+ def tag_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def tag_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'bind', tagid(tag)], seq)
+ self
+ end
+ def tag_bindinfo(tag, seq=nil)
+ _bindinfo([@path, 'bind', tagid(tag)], seq)
+ end
+
+ def button_activate(tag)
+ tk_send('button', 'activate', tagid(tag))
+ self
+ end
+
+ def button_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'button', 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def button_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'button', 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def button_bind_remove(tag, seq)
+ _bind_remove([@path, 'button', 'bind', tagid(tag)], seq)
+ self
+ end
+ def button_bindinfo(tag, seq=nil)
+ _bindinfo([@path, 'button', 'bind', tagid(tag)], seq)
+ end
+
+ def close(*tags)
+ tk_send('close', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+ def close_recurse(*tags)
+ tk_send('close', '-recurse', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def column_activate(column=None)
+ if column == None
+ tk_send('column', 'activate')
+ else
+ tk_send('column', 'activate', column)
+ self
+ end
+ end
+
+ def column_delete(*fields)
+ tk_send('column', 'delete', *fields)
+ self
+ end
+ def column_insert(pos, field, *opts)
+ tk_send('column', 'insert', pos, field, *opts)
+ self
+ end
+ def column_invoke(field)
+ tk_send('column', 'invoke', field)
+ self
+ end
+ def column_move(name, dest)
+ tk_send('column', 'move', name, dest)
+ self
+ end
+ def column_names()
+ simplelist(tk_send('column', 'names'))
+ end
+ def column_nearest(x, y=None)
+ tk_send('column', 'nearest', x, y)
+ end
+
+ def curselection
+ simplelist(tk_send('curselection')).collect{|id| tagid2obj(id)}
+ end
+
+ def delete(*tags)
+ tk_send('delete', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def entry_activate(tag)
+ tk_send('entry', 'activate', tagid(tag))
+ self
+ end
+ def entry_children(tag, first=None, last=None)
+ simplelist(tk_send('entry', 'children', tagid(tag),
+ first, last)).collect{|id| tagid2obj(id)}
+ end
+ def entry_delete(tag, first=None, last=None)
+ tk_send('entry', 'delete', tagid(tag), first, last)
+ end
+ def entry_before?(tag1, tag2)
+ bool(tk_send('entry', 'isbefore', tagid(tag1), tagid(tag2)))
+ end
+ def entry_hidden?(tag)
+ bool(tk_send('entry', 'ishidden', tagid(tag)))
+ end
+ def entry_open?(tag)
+ bool(tk_send('entry', 'isopen', tagid(tag)))
+ end
+
+ def entry_size(tag)
+ number(tk_send('entry', 'size', tagid(tag)))
+ end
+ def entry_size_recurse(tag)
+ number(tk_send('entry', 'size', '-recurse', tagid(tag)))
+ end
+
+ def _search_flags(keys)
+ keys = _symbolkey2str(keys)
+ keys['exact'] = None if keys.delete('exact')
+ keys['glob'] = None if keys.delete('glob')
+ keys['regexp'] = None if keys.delete('regexp')
+ keys['nonmatching'] = None if keys.delete('nonmatching')
+ end
+ private :_search_flags
+
+ ################################
+
+ class FindExecFlagValue < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?W, ?w, :widget ],
+ [ ?p, ?s, :name ],
+ [ ?P, ?s, :fullpath ],
+ [ ?#, ?x, :node_id ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ []
+ end
+ end
+
+ def _find_exec_flag_value(val)
+ if val.kind_of?(Array)
+ cmd, *args = val
+ #FindExecFlagValue.new(cmd, args.join(' '))
+ FindExecFlagValue.new(cmd, *args)
+ elsif TkComm._callback_entry?(val)
+ FindExecFlagValue.new(val)
+ else
+ val
+ end
+ end
+
+ ################################
+
+ def find(first, last, keys={})
+ keys = _search_flags(keys)
+ keys['exec'] = _find_exec_flag_value(keys['exec']) if keys.key?('exec')
+ args = hash_kv(keys) << '--' << tagid(first) << tagid(last)
+ simplelist(tk_send('find', *args)).collect{|id| tagid2obj(id)}
+ end
+
+ def tag_focus(tag)
+ tk_send('focus', tagid(tag))
+ self
+ end
+ def get(*tags)
+ simplelist(tk_send('get', *(tags.collect{|tag| tagid(tag)})))
+ end
+ def get_full(*tags)
+ simplelist(tk_send('get', '-full', *(tags.collect{|tag| tagid(tag)})))
+ end
+
+ def hide(*tags)
+ if tags[-1].kind_of?(Hash)
+ keys = tags.pop
+ else
+ keys = {}
+ end
+ keys = _search_flags(keys)
+ args = hash_kv(keys) << '--'
+ args.concat(tags.collect{|t| tagid(t)})
+ tk_send('hide', *args)
+ self
+ end
+
+ def index(str)
+ tagid2obj(tk_send('index', str))
+ end
+ def index_at(tag, str)
+ tagid2obj(tk_send('index', '-at', tagid(tag), str))
+ end
+ def index_at_path(tag, str)
+ tagid2obj(tk_send('index', '-at', tagid(tag), '-path', str))
+ end
+
+ def insert(pos, parent=nil, keys={})
+ Tk::BLT::Treeview::Node.new(pos, parent, keys)
+ end
+ def insert_at(tag, pos, parent=nil, keys={})
+ if parent.kind_of?(Hash)
+ keys = parent
+ parent = nil
+ end
+
+ keys = _symbolkey2str(keys)
+ keys['at'] = tagid(tag)
+
+ Tk::BLT::Treeview::Node.new(pos, parent, keys)
+ end
+
+ def move_before(tag, dest)
+ tk_send('move', tagid(tag), 'before', tagid(dest))
+ self
+ end
+ def move_after(tag, dest)
+ tk_send('move', tagid(tag), 'after', tagid(dest))
+ self
+ end
+ def move_into(tag, dest)
+ tk_send('move', tagid(tag), 'into', tagid(dest))
+ self
+ end
+
+ def nearest(x, y, var=None)
+ tagid2obj(tk_send('nearest', x, y, var))
+ end
+
+ def open(*tags)
+ tk_send('open', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+ def open_recurse(*tags)
+ tk_send('open', '-recurse', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def range(first, last)
+ simplelist(tk_send('range', tagid(first), tagid(last))).collect{|id|
+ tagid2obj(id)
+ }
+ end
+ def range_open(first, last)
+ simplelist(tk_send('range', '-open',
+ tagid(first), tagid(last))).collect{|id|
+ tagid2obj(id)
+ }
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(tag)
+ tk_send_without_enc('see', tagid(tag))
+ self
+ end
+ def see_anchor(anchor, tag)
+ tk_send_without_enc('see', '-anchor', anchor, tagid(tag))
+ self
+ end
+
+ def selection_anchor(tag)
+ tk_send_without_enc('selection', 'anchor', tagid(tag))
+ self
+ end
+ def selection_cancel()
+ tk_send_without_enc('selection', 'cancel')
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', tagid(first), tagid(last))
+ self
+ end
+ def selection_clear_all()
+ tk_send_without_enc('selection', 'clearall')
+ self
+ end
+ def selection_mark(tag)
+ tk_send_without_enc('selection', 'mark', tagid(tag))
+ self
+ end
+ def selection_include?(tag)
+ bool(tk_send('selection', 'include', tagid(tag)))
+ end
+ def selection_present?()
+ bool(tk_send('selection', 'present'))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', tagid(first), tagid(last))
+ self
+ end
+ def selection_toggle(first, last=None)
+ tk_send_without_enc('selection', 'toggle', tagid(first), tagid(last))
+ self
+ end
+
+ def show(*tags)
+ if tags[-1].kind_of?(Hash)
+ keys = tags.pop
+ else
+ keys = {}
+ end
+ keys = _search_flags(keys)
+ args = hash_kv(keys) << '--'
+ args.concat(tags.collect{|t| tagid(t)})
+ tk_send('show', *args)
+ self
+ end
+
+ def sort_auto(mode)
+ tk_send('sort', 'auto', mode)
+ self
+ end
+ def sort_auto=(mode)
+ tk_send('sort', 'auto', mode)
+ mode
+ end
+ def sort_auto?
+ bool(tk_send('sort', 'auto'))
+ end
+ def sort_once(*tags)
+ tk_send('sort', 'once', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+ def sort_once_recurse(*tags)
+ tk_send('sort', 'once', '-recurse', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def tag_add(tag, *ids)
+ tk_send('tag', 'add', tagid(tag), *ids)
+ self
+ end
+ def tag_delete(tag, *ids)
+ tk_send('tag', 'delete', tagid(tag), *ids)
+ self
+ end
+ def tag_forget(tag)
+ tk_send('tag', 'forget', tagid(tag))
+ self
+ end
+ def tag_names(id=nil)
+ id = (id)? tagid(id): None
+
+ simplelist(tk_send('tag', 'nodes', id)).collect{|tag|
+ Tk::BLT::Treeview::Tag.id2obj(self, tag)
+ }
+ end
+ def tag_nodes(tag)
+ simplelist(tk_send('tag', 'nodes', tagid(tag))).collect{|id|
+ Tk::BLT::Treeview::Node.id2obj(self, id)
+ }
+ end
+
+ def text_apply
+ tk_send('text', 'apply')
+ self
+ end
+ def text_cancel
+ tk_send('text', 'cancel')
+ self
+ end
+
+ def text_delete(first, last)
+ tk_send('text', 'delete', first, last)
+ self
+ end
+ def text_get(x, y)
+ tk_send('text', 'get', x, y)
+ end
+ def text_get_root(x, y)
+ tk_send('text', 'get', '-root', x, y)
+ end
+ def text_icursor(idx)
+ tk_send('text', 'icursor', idx)
+ self
+ end
+ def text_index(idx)
+ num_or_str(tk_send('text', 'index', idx))
+ end
+ def text_insert(idx, str)
+ tk_send('text', 'insert', idx, str)
+ self
+ end
+
+ def text_selection_adjust(idx)
+ tk_send('text', 'selection', 'adjust', idx)
+ self
+ end
+ def text_selection_clear
+ tk_send('text', 'selection', 'clear')
+ self
+ end
+ def text_selection_from(idx)
+ tk_send('text', 'selection', 'from', idx)
+ self
+ end
+ def text_selection_present
+ num_or_str(tk_send('text', 'selection', 'present'))
+ end
+ def text_selection_range(start, last)
+ tk_send('text', 'selection', 'range', start, last)
+ self
+ end
+ def text_selection_to(idx)
+ tk_send('text', 'selection', 'to', idx)
+ self
+ end
+
+ def toggle(tag)
+ tk_send('toggle', tagid(tag))
+ self
+ end
+end
+
+######################################
+
+module Tk::BLT::Treeview::TagOrID_Methods
+ def bbox
+ @tree.bbox(self)
+ end
+ def screen_bbox
+ @tree.screen_bbox(self)
+ end
+
+ def bind(seq, *args)
+ @tree.tag_bind(self, seq, *args)
+ self
+ end
+ def bind_append(seq, *args)
+ @tree.tag_bind_append(self, seq, *args)
+ self
+ end
+ def bind_remove(seq)
+ @tree.tag_bind_remove(self, seq)
+ self
+ end
+ def bindinfo(seq=nil)
+ @tree.tag_bindinfo(self, seq)
+ end
+
+ def button_activate
+ @tree.button_activate(self)
+ self
+ end
+
+ def button_bind(seq, *args)
+ @tree.button_bind(self, seq, *args)
+ self
+ end
+ def button_bind_append(seq, *args)
+ @tree.button_bind_append(self, seq, *args)
+ self
+ end
+ def button_bind_remove(seq)
+ @tree.button_bind_remove(self, seq)
+ self
+ end
+ def button_bindinfo(seq=nil)
+ @tree.button_bindinfo(self, seq)
+ end
+
+ def close
+ @tree.close(self)
+ self
+ end
+ def close_recurse
+ @tree.close_recurse(self)
+ self
+ end
+
+ def delete
+ @tree.delete(self)
+ self
+ end
+
+ def entry_activate
+ @tree.entry_activate(self)
+ self
+ end
+ def entry_children(first=None, last=None)
+ @tree.entry_children(self, first, last)
+ end
+ def entry_delete(first=None, last=None)
+ @tree.entry_delete(self, first, last)
+ end
+ def entry_before?(tag)
+ @tree.entry_before?(self, tag)
+ end
+ def entry_hidden?
+ @tree.entry_before?(self)
+ end
+ def entry_open?
+ @tree.entry_open?(self)
+ end
+
+ def entry_size
+ @tree.entry_size(self)
+ end
+ def entry_size_recurse
+ @tree.entry_size_recurse(self)
+ end
+
+ def focus
+ @tree.tag_focus(self)
+ self
+ end
+
+ def get
+ @tree.get(self)
+ end
+ def get_full
+ @tree.get_full(self)
+ end
+
+ def hide
+ @tree.hide(self)
+ self
+ end
+
+ def index(str)
+ @tree.index_at(self, str)
+ end
+ def index_path(str)
+ @tree.index_at_path(self, str)
+ end
+
+ def insert(pos, parent=nil, keys={})
+ @tree.insert_at(self, pos, parent, keys)
+ end
+
+ def move_before(dest)
+ @tree.move_before(self, dest)
+ self
+ end
+ def move_after(dest)
+ @tree.move_after(self, dest)
+ self
+ end
+ def move_into(dest)
+ @tree.move_into(self, dest)
+ self
+ end
+
+ def open
+ @tree.open(self)
+ self
+ end
+ def open_recurse
+ @tree.open_recurse(self)
+ self
+ end
+
+ def range_to(tag)
+ @tree.range(self, tag)
+ end
+ def range_open_to(tag)
+ @tree.range(self, tag)
+ end
+
+ def see
+ @tree.see(self)
+ self
+ end
+ def see_anchor(anchor)
+ @tree.see_anchor(anchor, self)
+ self
+ end
+
+ def selection_anchor
+ @tree.selection_anchor(self)
+ self
+ end
+ def selection_clear
+ @tree.selection_clear(self)
+ self
+ end
+ def selection_mark
+ @tree.selection_mark(self)
+ self
+ end
+ def selection_include?
+ @tree.selection_include?(self)
+ end
+ def selection_set
+ @tree.selection_set(self)
+ self
+ end
+ def selection_toggle
+ @tree.selection_toggle(self)
+ self
+ end
+
+ def show
+ @tree.show(self)
+ self
+ end
+
+ def sort_once
+ @tree.sort_once(self)
+ self
+ end
+ def sort_once_recurse
+ @tree.sort_once_recurse(self)
+ self
+ end
+
+ def toggle
+ @tree.toggle(self)
+ self
+ end
+end
+
+######################################
+
+class Tk::BLT::Treeview::Node < TkObject
+ include Tk::BLT::Treeview::TagOrID_Methods
+
+ TreeNodeID_TBL = TkCore::INTERP.create_table
+
+ (TreeNode_ID = ['blt_treeview_node'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeNodeID_TBL.mutex.synchronize{
+ if TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, nil, nil, 'node'=>Integer(id))
+ unless (tk_call(@tpath, 'get', id)).empty?
+ id = Integer(id)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id
+ TreeNodeID_TBL[@tpath] ||= {}
+ TreeNodeID_TBL[@tpath][@id] = self
+ }
+ obj
+ else
+ id
+ end
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(tree, pos, parent=nil, keys={})
+ if parent.kind_of?(Hash)
+ keys = parent
+ parent = nil
+ end
+
+ keys = _symbolkey2str(keys)
+ tpath = tree.path
+
+ TreeNodeID_TBL.mutex.synchronize{
+ TreeNodeID_TBL[tpath] ||= {}
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, pos, parent) if parent
+ return obj
+ end
+
+ #super(tree, pos, parent, keys)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, pos, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
+ end
+
+ def initialize(tree, pos, parent, keys)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if (id = keys['node'])
+ # if tk_call(@tpath, 'get', id).empty?
+ # fail RuntimeError, "not exist the node '#{id}'"
+ # end
+ @path = @id = id
+ tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
+ configure(keys) if keys && ! keys.empty?
+ else
+ name = nil
+ TreeNode_ID.mutex.synchronize{
+ name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeNode_ID[1].succ!
+ }
+
+ at = keys.delete['at']
+
+ if parent
+ if parent.kind_of?(Tk::BLT::Treeview::Node) ||
+ parent.kind_of?(Tk::BLT::Treeview::Tag)
+ path = [get_full(parent.id)[0], name]
+ at = nil # ignore 'at' option
+ else
+ path = [parent.to_s, name]
+ end
+ else
+ path = name
+ end
+
+ if at
+ @id = tk_call(@tpath, 'insert', '-at', tagid(at), pos, path, keys)
+ else
+ @id = tk_call(@tpath, 'insert', pos, path, keys)
+ end
+ @path = @id
+ end
+ end
+
+ def id
+ @id
+ end
+end
+
+######################################
+
+class Tk::BLT::Treeview::Tag < TkObject
+ include Tk::BLT::Treeview::TagOrID_Methods
+
+ TreeTagID_TBL = TkCore::INTERP.create_table
+
+ (TreeTag_ID = ['blt_treeview_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ def self.id2obj(tree, name)
+ tpath = tree.path
+ TreeTagID_TBL.mutex.synchronize{
+ if TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][name]
+ TreeTagID_TBL[tpath][name]
+ else
+ #self.new(tree, name)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = name
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new_by_name(tree, name, *ids)
+ TreeTagID_TBL.mutex.synchronize{
+ unless (obj = TreeTagID_TBL[tree.path][name])
+ (obj = self.allocate).instance_eval{
+ initialize(tree, name, ids)
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ end
+ obj
+ }
+ end
+
+ def self.new(tree, *ids)
+ TreeTagID_TBL.mutex.synchronize{
+ (obj = self.allocate).instance_eval{
+ if tree.kind_of?(Array)
+ initialize(tree[0], tree[1], ids)
+ else
+ initialize(tree, nil, ids)
+ end
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ }
+ end
+
+ def initialize(tree, name, ids)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if name
+ @path = @id = name
+ else
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeTag_ID[1].succ!
+ }
+ end
+
+ unless ids.empty?
+ tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
+ end
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BLT::Treeview::Node) \
+ || tag.kind_of?(Tk::BLT::Treeview::Tag)
+ tag.id
+ else
+ tag
+ end
+ end
+ private :tagid
+
+ def id
+ @id
+ end
+
+ def add(*ids)
+ tk_call(@tpath, 'tag', 'add', @id, *(ids{|id| tagid(id)}))
+ self
+ end
+
+ def remove(*ids)
+ tk_call(@tpath, 'tag', 'delete', @id, *(ids{|id| tagid(id)}))
+ self
+ end
+
+ def forget
+ tk_call(@tpath, 'tag', 'forget', @id)
+ self
+ end
+
+ def nodes
+ simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|id|
+ Tk::BLT::Treeview::Node.id2obj(@tree, id)
+ }
+ end
+end
+
+class Tk::BLT::Hiertable
+ TkCommandNames = ['::blt::hiertable'.freeze].freeze
+ WidgetClassName = 'Hiertable'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb
new file mode 100644
index 0000000..8996f7c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb
@@ -0,0 +1,141 @@
+#
+# tkextlib/blt/unix_dnd.rb
+#
+# *** This is alpha version, because there is no document on BLT. ***
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module DnD
+ extend TkCore
+
+ TkCommandNames = ['::blt::dnd'.freeze].freeze
+
+ ##############################
+
+ extend TkItemConfigMethod
+
+ class << self
+ def __item_cget_cmd(id)
+ ['::blt::dnd', *id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ ['::blt::dnd', *id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def cget_tkstring(win, option)
+ itemcget_tkstring(['cget', win], option)
+ end
+ def cget(win, option)
+ itemcget(['cget', win], option)
+ end
+ def cget_strict(win, option)
+ itemcget_strict(['cget', win], option)
+ end
+ def configure(win, slot, value=None)
+ itemconfigure(['configure', win], slot, value)
+ end
+ def configinfo(win, slot=nil)
+ itemconfiginfo(['configure', win], slot)
+ end
+ def current_configinfo(win, slot=nil)
+ current_itemconfiginfo(['configure', win], slot)
+ end
+
+ def token_cget_tkstring(win, option)
+ itemcget_tkstring(['token', 'cget', win], option)
+ end
+ def token_cget(win, option)
+ itemcget(['token', 'cget', win], option)
+ end
+ def token_cget_strict(win, option)
+ itemcget_strict(['token', 'cget', win], option)
+ end
+ def token_configure(win, slot, value=None)
+ itemconfigure(['token', 'configure', win], slot, value)
+ end
+ def token_configinfo(win, slot=nil)
+ itemconfiginfo(['token', 'configure', win], slot)
+ end
+ def current_token_configinfo(win, slot=nil)
+ current_itemconfiginfo(['token', 'configure', win], slot)
+ end
+
+ def token_windowconfigure(win, slot, value=None)
+ itemconfigure(['token', 'window', win], slot, value)
+ end
+ def token_windowconfiginfo(win, slot=nil)
+ itemconfiginfo(['token', 'window', win], slot)
+ end
+ def current_token_windowconfiginfo(win, slot=nil)
+ current_itemconfiginfo(['token', 'window', win], slot)
+ end
+ end
+
+ ##############################
+
+ def self.cancel(win)
+ tk_call('::blt::dnd', 'cancel', *wins)
+ end
+ def self.delete(*wins)
+ tk_call('::blt::dnd', 'delete', *wins)
+ end
+ def self.delete_source(*wins)
+ tk_call('::blt::dnd', 'delete', '-source', *wins)
+ end
+ def self.delete_target(*wins)
+ tk_call('::blt::dnd', 'delete', '-target', *wins)
+ end
+ def self.drag(win, x, y, token=None)
+ tk_call('::blt::dnd', 'drag', win, x, y, token)
+ end
+ def self.drop(win, x, y, token=None)
+ tk_call('::blt::dnd', 'drop', win, x, y, token)
+ end
+ def self.get_data(win, fmt=nil, cmd=nil)
+ if fmt
+ tk_call('::blt::dnd', 'getdata', win, fmt, cmd)
+ else
+ list(tk_call('::blt::dnd', 'getdata', win))
+ end
+ end
+ def self.names(pat=None)
+ list(tk_call('::blt::dnd', 'names', pat))
+ end
+ def self.source_names(pat=None)
+ list(tk_call('::blt::dnd', 'names', '-source', pat))
+ end
+ def self.target_names(pat=None)
+ list(tk_call('::blt::dnd', 'names', '-target', pat))
+ end
+ def self.pull(win, fmt)
+ tk_call('::blt::dnd', 'pull', win, fmt)
+ end
+ def self.register(win, keys={})
+ tk_call('::blt::dnd', 'register', win, keys)
+ end
+ def self.select(win, x, y, timestamp)
+ tk_call('::blt::dnd', 'select', win, x, y, timestamp)
+ end
+ def self.set_data(win, fmt=nil, cmd=nil)
+ if fmt
+ tk_call('::blt::dnd', 'setdata', win, fmt, cmd)
+ else
+ list(tk_call('::blt::dnd', 'setdata', win))
+ end
+ end
+ def self.token(*args)
+ tk_call('::blt::dnd', 'token', *args)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb
new file mode 100644
index 0000000..742e901
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb
@@ -0,0 +1,256 @@
+#
+# tkextlib/blt/vector.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Vector < TkVariable
+ TkCommandNames = ['::blt::vector'.freeze].freeze
+
+ def self.create(*args)
+ tk_call('::blt::vector', 'create', *args)
+ end
+
+ def self.destroy(*args)
+ tk_call('::blt::vector', 'destroy', *args)
+ end
+
+ def self.expr(expression)
+ tk_call('::blt::vector', 'expr', expression)
+ end
+
+ def self.names(pat=None)
+ list = simplelist(tk_call('::blt::vector', 'names', pat))
+ TkVar_ID_TBL.mutex.synchronize{
+ list.collect{|name|
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
+ TkVar_ID_TBL[name[2..-1]]
+ else
+ name
+ end
+ }
+ }
+ end
+
+ ####################################
+
+ def initialize(size=nil, keys={})
+ if size.kind_of?(Hash)
+ keys = size
+ size = nil
+ end
+ if size.kind_of?(Array)
+ # [first, last]
+ size = size.join(':')
+ end
+ if size
+ @id = TkCore::INTERP._invoke('::blt::vector', 'create',
+ "#auto(#{size})", *hash_kv(keys))
+ else
+ @id = TkCore::INTERP._invoke('::blt::vector', 'create',
+ "#auto", *hash_kv(keys))
+ end
+
+ TkVar_ID_TBL.mutex.synchronize{
+ TkVar_ID_TBL[@id] = self
+ }
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ # teach Tk-ip that @id is global var
+ TkCore::INTERP._invoke_without_enc('global', @id)
+ end
+
+ def destroy
+ tk_call('::blt::vector', 'destroy', @id)
+ end
+
+ def inspect
+ '#<Tk::BLT::Vector: ' + @id + '>'
+ end
+
+ def to_s
+ @id
+ end
+
+ def *(item)
+ list(tk_call(@id, '*', item))
+ end
+
+ def +(item)
+ list(tk_call(@id, '+', item))
+ end
+
+ def -(item)
+ list(tk_call(@id, '-', item))
+ end
+
+ def /(item)
+ list(tk_call(@id, '/', item))
+ end
+
+ def append(*vectors)
+ tk_call(@id, 'append', *vectors)
+ end
+
+ def binread(channel, len=None, keys={})
+ if len.kind_of?(Hash)
+ keys = len
+ len = None
+ end
+ keys = _symbolkey2str(keys)
+ keys['swap'] = None if keys.delete('swap')
+ tk_call(@id, 'binread', channel, len, keys)
+ end
+
+ def clear()
+ tk_call(@id, 'clear')
+ self
+ end
+
+ def delete(*indices)
+ tk_call(@id, 'delete', *indices)
+ self
+ end
+
+ def dup_vector(vec)
+ tk_call(@id, 'dup', vec)
+ self
+ end
+
+ def expr(expression)
+ tk_call(@id, 'expr', expression)
+ self
+ end
+
+ def index(idx, val=None)
+ number(tk_call(@id, 'index', idx, val))
+ end
+
+ def [](idx)
+ index(idx)
+ end
+
+ def []=(idx, val)
+ index(idx, val)
+ end
+
+ def length()
+ number(tk_call(@id, 'length'))
+ end
+
+ def length=(size)
+ number(tk_call(@id, 'length', size))
+ end
+
+ def merge(*vectors)
+ tk_call(@id, 'merge', *vectors)
+ self
+ end
+
+ def normalize(vec=None)
+ tk_call(@id, 'normalize', vec)
+ self
+ end
+
+ def notify(keyword)
+ tk_call(@id, 'notify', keyword)
+ self
+ end
+
+ def offset()
+ number(tk_call(@id, 'offset'))
+ end
+
+ def offset=(val)
+ number(tk_call(@id, 'offset', val))
+ end
+
+ def random()
+ tk_call(@id, 'random')
+ end
+
+ def populate(vector, density=None)
+ tk_call(@id, 'populate', vector, density)
+ self
+ end
+
+ def range(first, last=None)
+ list(tk_call(@id, 'range', first, last))
+ end
+
+ def search(val1, val2=None)
+ list(tk_call(@id, 'search', val1, val2))
+ end
+
+ def set(item)
+ tk_call(@id, 'set', item)
+ self
+ end
+
+ def seq(start, finish=None, step=None)
+ tk_call(@id, 'seq', start, finish, step)
+ self
+ end
+
+ def sort(*vectors)
+ tk_call(@id, 'sort', *vectors)
+ self
+ end
+
+ def sort_reverse(*vectors)
+ tk_call(@id, 'sort', '-reverse', *vectors)
+ self
+ end
+
+ def split(*vectors)
+ tk_call(@id, 'split', *vectors)
+ self
+ end
+
+ def variable(var)
+ tk_call(@id, 'variable', var)
+ self
+ end
+ end
+
+ class VectorAccess < Vector
+ def self.new(name)
+ TkVar_ID_TBL.mutex.synchronize{
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(name)
+ TkVar_ID_TBL[@id] = self
+ }
+ obj
+ end
+ }
+ end
+
+ def initialize(vec_name)
+ @id = vec_name
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ # teach Tk-ip that @id is global var
+ TkCore::INTERP._invoke_without_enc('global', @id)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb
new file mode 100644
index 0000000..292623f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/blt/watch.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Watch < TkObject
+ extend TkCore
+
+ TkCommandNames = ['::blt::watch'.freeze].freeze
+
+ WATCH_ID_TBL = TkCore::INTERP.create_table
+
+ (BLT_WATCH_ID = ['blt_watch_id'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ WATCH_ID_TBL.mutex.synchronize{ WATCH_ID_TBL.clear }
+ }
+
+ def self.names(state = None)
+ lst = tk_split_list(tk_call('::blt::watch', 'names', state))
+ WATCH_ID_TBL.mutex.synchronize{
+ lst.collect{|name|
+ WATCH_ID_TBL[name] || name
+ }
+ }
+ end
+
+ def __numval_optkeys
+ ['maxlevel']
+ end
+ private :__numval_optkeys
+
+ def __boolval_optkeys
+ ['active']
+ end
+ private :__boolval_optkeys
+
+ def __config_cmd
+ ['::blt::watch', 'configure', self.path]
+ end
+ private :__config_cmd
+
+ def initialize(name = nil, keys = {})
+ if name.kind_of?(Hash)
+ keys = name
+ name = nil
+ end
+
+ if name
+ @id = name.to_s
+ else
+ BLT_WATCH_ID.mutex.synchronize{
+ @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
+ BLT_WATCH_ID[1].succ!
+ }
+ end
+
+ @path = @id
+
+ WATCH_ID_TBL.mutex.synchronize{
+ WATCH_ID_TBL[@id] = self
+ }
+ tk_call('::blt::watch', 'create', @id, *hash_kv(keys))
+ end
+
+ def activate
+ tk_call('::blt::watch', 'activate', @id)
+ self
+ end
+ def deactivate
+ tk_call('::blt::watch', 'deactivate', @id)
+ self
+ end
+ def delete
+ tk_call('::blt::watch', 'delete', @id)
+ self
+ end
+ def info
+ ret = []
+ lst = tk_split_simplelist(tk_call('::blt::watch', 'info', @id))
+ until lst.empty?
+ k, v, *lst = lst
+ k = k[1..-1]
+ case k
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ begin
+ v = number(v)
+ rescue
+ v = nil
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ v = num_or_str(v)
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ begin
+ v = bool(v)
+ rescue
+ v = nil
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ v = simplelist(v)
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ v = list(v)
+
+ else
+ if v.index('{')
+ v = tk_split_list(v)
+ else
+ v = tk_tcl2ruby(v)
+ end
+ end
+
+ ret << [k, v]
+ end
+
+ ret
+ end
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ v = cget(slot)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ [slot, v]
+ else
+ {slot=>v}
+ end
+ else
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ info
+ else
+ Hash[*(info.flatten)]
+ end
+ end
+ end
+ def cget_strict(key)
+ key = key.to_s
+ begin
+ info.assoc(key)[1]
+ rescue
+ fail ArgumentError, "unknown option '#{key}'"
+ end
+ end
+ def cget(key)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ cget_strict(key)
+ else
+ begin
+ cget_strict(key)
+ rescue => e
+ if current_configinfo.has_key?(key.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb
new file mode 100644
index 0000000..7ac6a0d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/blt/win_printer.rb
+#
+# *** Windows only ***
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Printer < TkObject
+ extend TkCore
+
+ TkCommandNames = ['::blt::printer'.freeze].freeze
+
+ def self.enum(attribute)
+ simplelist(tk_call('::blt::printer', 'enum', attribute))
+ end
+
+ def self.names(pat=None)
+ simplelist(tk_call('::blt::printer', 'names', pat))
+ end
+
+ def self.open(printer)
+ self.new(printer)
+ end
+
+ #################################
+
+ def initialize(printer)
+ @printer_id = tk_call('::blt::printer', 'open', printer)
+ end
+
+ def close
+ tk_call('::blt::print', 'close', @printer_id)
+ self
+ end
+ def get_attrs(var)
+ tk_call('::blt::print', 'getattrs', @printer_id, var)
+ var
+ end
+ def set_attrs(var)
+ tk_call('::blt::print', 'setattrs', @printer_id, var)
+ self
+ end
+ def snap(win)
+ tk_call('::blt::print', 'snap', @printer_id, win)
+ self
+ end
+ def write(str)
+ tk_call('::blt::print', 'write', @printer_id, str)
+ self
+ end
+ def write_with_title(title, str)
+ tk_call('::blt::print', 'write', @printer_id, title, str)
+ self
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb
new file mode 100644
index 0000000..03bdb60
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb
@@ -0,0 +1,107 @@
+#
+# tkextlib/blt/winop.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Winop
+ extend TkCore
+
+ TkCommandNames = ['::blt::winop'.freeze].freeze
+ end
+ WinOp = Winop
+end
+
+class << Tk::BLT::Winop
+ def changes(win)
+ tk_call('::blt::winop', 'changes', win)
+ end
+
+ def colormap(win)
+ Hash[*list(tk_call('::blt::winop', 'colormap', win))]
+ end
+
+ def convolve(src, dest, filter)
+ tk_call('::blt::winop', 'convolve', src, dest, filter)
+ end
+
+ def image_convolve(src, dest, filter)
+ tk_call('::blt::winop', 'image', 'convolve', src, dest, filter)
+ end
+ def image_gradient(photo, left, right, type)
+ tk_call('::blt::winop', 'image', 'gradient', photo, left, right, type)
+ end
+ def image_read_jpeg(file, photo)
+ tk_call('::blt::winop', 'image', 'readjpeg', file, photo)
+ end
+ def image_resample(src, dest, horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'image', 'resample',
+ src, dest, horiz_filter, vert_filter)
+ end
+ def image_rotate(src, dest, angle)
+ tk_call('::blt::winop', 'image', 'rotate', src, dest, angle)
+ end
+ def image_snap(win, photo, width=None, height=None)
+ tk_call('::blt::winop', 'image', 'snap', win, photo, width, height)
+ end
+ def image_subsample(src, dest, x, y, width, height,
+ horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'image', 'subsample',
+ src, dest, x, y, width, height, horiz_filter, vert_filter)
+ end
+
+ def quantize(src, dest, colors)
+ tk_call('::blt::winop', 'quantize', src, dest, colors)
+ end
+
+ def query()
+ tk_call('::blt::winop', 'query')
+ end
+
+ def read_jpeg(file, photo)
+ tk_call('::blt::winop', 'readjpeg', file, photo)
+ end
+
+ def resample(src, dest, horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'resample',
+ src, dest, horiz_filter, vert_filter)
+ end
+
+ def subsample(src, dest, x, y, width, height,
+ horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'subsample',
+ src, dest, x, y, width, height, horiz_filter, vert_filter)
+ end
+
+ def raise(*wins)
+ tk_call('::blt::winop', 'raise', *wins)
+ end
+
+ def lower(*wins)
+ tk_call('::blt::winop', 'lower', *wins)
+ end
+
+ def map(*wins)
+ tk_call('::blt::winop', 'map', *wins)
+ end
+
+ def unmap(*wins)
+ tk_call('::blt::winop', 'unmap', *wins)
+ end
+
+ def move(win, x, y)
+ tk_call('::blt::winop', 'move', win, x, y)
+ end
+
+ def snap(win, photo)
+ tk_call('::blt::winop', 'snap', win, photo)
+ end
+
+ def warpto(win = None)
+ tk_call('::blt::winop', 'warpto', win)
+ end
+ alias warp_to warpto
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget.rb
new file mode 100644
index 0000000..7a1eff5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget.rb
@@ -0,0 +1,153 @@
+#
+# BWidget extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/bwidget/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('BWidget', '1.7')
+TkPackage.require('BWidget')
+
+module Tk
+ module BWidget
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+ # Require autoload-symbols which is a same name as widget classname.
+ # Those are used at TkComm._genobj_for_tkwidget method.
+
+ extend TkCore
+
+ LIBRARY = tk_call('set', '::BWIDGET::LIBRARY')
+
+ PACKAGE_NAME = 'BWidget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('BWidget')
+ rescue
+ ''
+ end
+ end
+
+ def self.XLFDfont(cmd, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ args.concat(hash_kv(keys))
+ end
+ tk_call('BWidget::XLFDfont', cmd, *args)
+ end
+
+ def self.assert(exp, msg=None)
+ tk_call('BWidget::assert', exp, msg)
+ end
+
+ def self.badOptionString(type, value, list)
+ tk_call('BWidget::badOptionString', type, value, list)
+ end
+
+ def self.bindMouseWheel(widget)
+ tk_call('BWidget::bindMouseWheel', widget)
+ end
+
+ def self.classes(klass)
+ list(tk_call('BWidget::classes', klass))
+ end
+
+ def self.clonename(menu)
+ tk_call('BWidget::clonename', menu)
+ end
+
+ def self.focus(opt, path)
+ tk_call('BWidget::focus', opt, path)
+ end
+
+ def self.get3dcolor(path, bgcolor)
+ tk_call('BWidget::get3dcolor', path, bgcolor)
+ end
+
+ def self.getname(name)
+ tk_call('BWidget::getname', name)
+ end
+
+ def self.grab(opt, path)
+ tk_call('BWidget::grab', opt, path)
+ end
+
+ def self.inuse(klass)
+ bool(tk_call('BWidget::inuse', klass))
+ end
+
+ def self.library(klass, *klasses)
+ tk_call('BWidget::library', klass, *klasses)
+ end
+
+ def self.lreorder(list, neworder)
+ tk_call('BWidget::lreorder', list, neworder)
+ end
+
+ def self.parsetext(text)
+ tk_call('BWidget::parsetext', text)
+ end
+
+ def self.place(path, w, h, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ args.concat(hash_kv(keys))
+ end
+ tk_call('BWidget::place', path, w, h, *(args.flatten))
+ end
+
+ def self.write(file, mode=None)
+ tk_call('BWidget::write', file, mode)
+ end
+
+ def self.wrongNumArgsString(str)
+ tk_call('BWidget::wrongNumArgsString', str)
+ end
+
+ ####################################################
+
+ autoload :ArrowButton, 'tkextlib/bwidget/arrowbutton'
+ autoload :Bitmap, 'tkextlib/bwidget/bitmap'
+ autoload :Button, 'tkextlib/bwidget/button'
+ autoload :ButtonBox, 'tkextlib/bwidget/buttonbox'
+ autoload :ComboBox, 'tkextlib/bwidget/combobox'
+ autoload :Dialog, 'tkextlib/bwidget/dialog'
+ autoload :DragSite, 'tkextlib/bwidget/dragsite'
+ autoload :DropSite, 'tkextlib/bwidget/dropsite'
+ autoload :DynamicHelp, 'tkextlib/bwidget/dynamichelp'
+ autoload :Entry, 'tkextlib/bwidget/entry'
+ autoload :Label, 'tkextlib/bwidget/label'
+ autoload :LabelEntry, 'tkextlib/bwidget/labelentry'
+ autoload :LabelFrame, 'tkextlib/bwidget/labelframe'
+ autoload :ListBox, 'tkextlib/bwidget/listbox'
+ autoload :MainFrame, 'tkextlib/bwidget/mainframe'
+ autoload :MessageDlg, 'tkextlib/bwidget/messagedlg'
+ autoload :NoteBook, 'tkextlib/bwidget/notebook'
+ autoload :PagesManager, 'tkextlib/bwidget/pagesmanager'
+ autoload :PanedWindow, 'tkextlib/bwidget/panedwindow'
+ autoload :PasswdDlg, 'tkextlib/bwidget/passwddlg'
+ autoload :ProgressBar, 'tkextlib/bwidget/progressbar'
+ autoload :ProgressDlg, 'tkextlib/bwidget/progressdlg'
+ autoload :ScrollableFrame, 'tkextlib/bwidget/scrollableframe'
+ autoload :ScrolledWindow, 'tkextlib/bwidget/scrolledwindow'
+ autoload :ScrollView, 'tkextlib/bwidget/scrollview'
+ autoload :SelectColor, 'tkextlib/bwidget/selectcolor'
+ autoload :SelectFont, 'tkextlib/bwidget/selectfont'
+ autoload :Separator, 'tkextlib/bwidget/separator'
+ autoload :SpinBox, 'tkextlib/bwidget/spinbox'
+ autoload :TitleFrame, 'tkextlib/bwidget/titleframe'
+ autoload :Tree, 'tkextlib/bwidget/tree'
+ autoload :Widget, 'tkextlib/bwidget/widget'
+
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb
new file mode 100644
index 0000000..13fe9e5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/arrowbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ArrowButton < Tk::BWidget::Button
+ end
+ end
+end
+
+class Tk::BWidget::ArrowButton
+ TkCommandNames = ['ArrowButton'.freeze].freeze
+ WidgetClassName = 'ArrowButton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb
new file mode 100644
index 0000000..6cfde20
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/bitmap.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tk/image'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Bitmap < TkPhotoImage
+ end
+ end
+end
+
+class Tk::BWidget::Bitmap
+ def initialize(name)
+ @path = tk_call_without_enc('Bitmap::get', name)
+ Tk_IMGTBL[@path] = self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb
new file mode 100644
index 0000000..e139fb6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb
@@ -0,0 +1,31 @@
+#
+# tkextlib/bwidget/button.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/button'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Button < Tk::Button
+ end
+ end
+end
+
+class Tk::BWidget::Button
+ TkCommandNames = ['Button'.freeze].freeze
+ WidgetClassName = 'Button'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
new file mode 100644
index 0000000..a6de33c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
@@ -0,0 +1,90 @@
+#
+# tkextlib/bwidget/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ButtonBox < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ButtonBox
+ TkCommandNames = ['ButtonBox'.freeze].freeze
+ WidgetClassName = 'ButtonBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include TkItemConfigMethod
+
+ def __boolval_optkeys
+ super() << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(Tk::Button)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def delete(idx)
+ tk_send('delete', tagid(idx))
+ self
+ end
+
+ def index(idx)
+ if idx.kind_of?(Tk::BWidget::Button)
+ name = idx[:name]
+ idx = name unless name.empty?
+ end
+ if idx.kind_of?(Tk::Button)
+ idx = idx[:text]
+ end
+ number(tk_send('index', idx.to_s))
+ end
+
+ def insert(idx, keys={}, &b)
+ win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb
new file mode 100644
index 0000000..16143df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/bwidget/combobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/listbox'
+require 'tkextlib/bwidget/spinbox'
+
+module Tk
+ module BWidget
+ class ComboBox < Tk::BWidget::SpinBox
+ end
+ end
+end
+
+class Tk::BWidget::ComboBox
+ include Scrollable
+
+ TkCommandNames = ['ComboBox'.freeze].freeze
+ WidgetClassName = 'ComboBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'autocomplete' << 'autopost'
+ end
+ private :__boolval_optkeys
+
+ def get_listbox(&b)
+ win = window(tk_send_without_enc('getlistbox'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def clear_value
+ tk_send_without_enc('clearvalue')
+ self
+ end
+ alias clearvalue clear_value
+
+ def icursor(idx)
+ tk_send_without_enc('icursor', idx)
+ end
+
+ def post
+ tk_send_without_enc('post')
+ self
+ end
+
+ def unpost
+ tk_send_without_enc('unpost')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb
new file mode 100644
index 0000000..3b0656f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb
@@ -0,0 +1,194 @@
+#
+# tkextlib/bwidget/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/buttonbox'
+
+module Tk
+ module BWidget
+ class Dialog < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::Dialog
+ TkCommandNames = ['Dialog'.freeze].freeze
+ WidgetClassName = 'Dialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include TkItemConfigMethod
+
+ def __numstrval_optkeys
+ super() << 'buttonwidth'
+ end
+ private :__numstrval_optkeys
+
+ def __strval_optkeys
+ super() << 'title' << 'geometry'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'transient' << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def initialize(parent=nil, keys=nil)
+ @relative = ''
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ @relative = keys['parent'] if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(keys)
+ elsif keys
+ keys = _symbolkey2str(keys)
+ @relative = keys.delete('parent') if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(parent, keys)
+ else
+ super(parent)
+ end
+ end
+
+ def create_self(keys)
+ cmd = self.class::TkCommandNames[0]
+ if keys and keys != None
+ tk_call_without_enc(cmd, @path, '-parent', @relative,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(cmd, @path, '-parent', @relative)
+ end
+ end
+
+ def cget_tkstring(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+ def cget_strict(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+ def cget(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ slot['parent'] = slot.delete('relative') if slot.key?('relative')
+ super(slot)
+ else
+ if slot.to_s == 'relative'
+ super('parent', value)
+ else
+ super(slot, value)
+ end
+ end
+ end
+
+ def configinfo(slot=nil)
+ if slot
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ else
+ ret = super()
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret << ['relative', 'parent']
+ else
+ ret['relative'] = 'parent'
+ end
+ end
+ end
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(Tk::Button)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_frame(&b)
+ win = window(tk_send('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_buttonbox(&b)
+ win = window(@path + '.bbox')
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def draw(focus_win=None)
+ tk_send('draw', focus_win)
+ end
+
+ def enddialog(ret)
+ tk_send('enddialog', ret)
+ end
+
+ def index(idx)
+ get_buttonbox.index(idx)
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+
+ def withdraw
+ tk_send('withdraw')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb
new file mode 100644
index 0000000..4d4de17
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb
@@ -0,0 +1,31 @@
+#
+# tkextlib/bwidget/dragsite.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DragSite
+ end
+ end
+end
+
+module Tk::BWidget::DragSite
+ include Tk
+ extend Tk
+
+ def self.include(klass, type, event)
+ tk_call('DragSite::include', klass, type, event)
+ end
+
+ def self.register(path, keys={})
+ tk_call('DragSite::register', path, *hash_kv(keys))
+ end
+
+ def self.set_drag(path, subpath, initcmd, endcmd, force=None)
+ tk_call('DragSite::setdrag', path, subpath, initcmd, endcmd, force)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb
new file mode 100644
index 0000000..e5e98fb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb
@@ -0,0 +1,39 @@
+#
+# tkextlib/bwidget/dropsite.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DropSite
+ end
+ end
+end
+
+module Tk::BWidget::DropSite
+ include Tk
+ extend Tk
+
+ def self.include(klass, type)
+ tk_call('DropSite::include', klass, type)
+ end
+
+ def self.register(path, keys={})
+ tk_call('DropSite::register', path, *hash_kv(keys))
+ end
+
+ def self.set_cursor(cursor)
+ tk_call('DropSite::setcursor', cursor)
+ end
+
+ def self.set_drop(path, subpath, dropover, drop, force=None)
+ tk_call('DropSite::setdrop', path, subpath, dropover, drop, force)
+ end
+
+ def self.set_operation(op)
+ tk_call('DropSite::setoperation', op)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
new file mode 100644
index 0000000..846e580
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
@@ -0,0 +1,63 @@
+#
+# tkextlib/bwidget/dynamichelp.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DynamicHelp
+ end
+ end
+end
+
+module Tk::BWidget::DynamicHelp
+ include Tk
+ extend Tk
+
+ def self.__pathname
+ 'DynamicHelp::configure'
+ end
+
+ def __strval_optkeys
+ super() << 'topbackground'
+ end
+ private :__strval_optkeys
+
+ def self.__cget_cmd
+ ['DynamicHelp::configure']
+ end
+
+ def self.__config_cmd
+ ['DynamicHelp::configure']
+ end
+
+ def self.cget_strict(slot)
+ slot = slot.to_s
+ info = {}
+ self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
+ fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
+ info.values[0]
+ end
+ def self.cget(slot)
+ self.current_configinfo(slot).values[0]
+ end
+
+ def self.add(widget, keys={})
+ tk_call('DynamicHelp::add', widget, *hash_kv(keys))
+ end
+
+ def self.delete(widget)
+ tk_call('DynamicHelp::delete', widget)
+ end
+
+ def self.include(klass, type)
+ tk_call('DynamicHelp::include', klass, type)
+ end
+
+ def self.sethelp(path, subpath, force=None)
+ tk_call('DynamicHelp::sethelp', path, subpath, force)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb
new file mode 100644
index 0000000..8dc4496
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/bwidget/entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Entry < Tk::Entry
+ end
+ end
+end
+
+class Tk::BWidget::Entry
+ include Scrollable
+
+ TkCommandNames = ['Entry'.freeze].freeze
+ WidgetClassName = 'Entry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext' << 'insertbackground'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled' << 'editable'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def invoke
+ tk_send_without_enc('invoke')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb
new file mode 100644
index 0000000..e8d9352
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb
@@ -0,0 +1,41 @@
+#
+# tkextlib/bwidget/label.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/label'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Label < Tk::Label
+ end
+ end
+end
+
+class Tk::BWidget::Label
+ TkCommandNames = ['Label'.freeze].freeze
+ WidgetClassName = 'Label'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def set_focus
+ tk_send_without_enc('setfocus')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb
new file mode 100644
index 0000000..16e7b46
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb
@@ -0,0 +1,80 @@
+#
+# tkextlib/bwidget/labelentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/labelframe'
+require 'tkextlib/bwidget/entry'
+
+module Tk
+ module BWidget
+ class LabelEntry < Tk::Entry
+ end
+ end
+end
+
+class Tk::BWidget::LabelEntry
+ include Scrollable
+
+ TkCommandNames = ['LabelEntry'.freeze].freeze
+ WidgetClassName = 'LabelEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext' << 'insertbackground' << 'entryfg' << 'entrybg'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'labelfont'
+ end
+ private :__font_optkeys
+
+ #def entrybind(*args)
+ # _bind([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ #def entrybind_append(*args)
+ # _bind_append([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ def entrybind_remove(*args)
+ _bind_remove([path, 'bind'], *args)
+ self
+ end
+
+ def entrybindinfo(*args)
+ _bindinfo([path, 'bind'], *args)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb
new file mode 100644
index 0000000..0710f21
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb
@@ -0,0 +1,52 @@
+#
+# tkextlib/bwidget/labelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/label'
+
+module Tk
+ module BWidget
+ class LabelFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::LabelFrame
+ TkCommandNames = ['LabelFrame'.freeze].freeze
+ WidgetClassName = 'LabelFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def self.align(*args)
+ tk_call('LabelFrame::align', *args)
+ end
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb
new file mode 100644
index 0000000..930491c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb
@@ -0,0 +1,361 @@
+#
+# tkextlib/bwidget/listbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ListBox < TkWindow
+ # is NOT a subclass of a listbox widget class.
+ # because it constructed on a canvas widget.
+
+ class Item < TkObject
+ end
+ end
+ end
+end
+
+class Tk::BWidget::ListBox
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['ListBox'.freeze].freeze
+ WidgetClassName = 'ListBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Event_for_Items < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # item idenfier
+ ]
+ end
+ end
+
+ def __boolval_optkeys
+ super() << 'autofocus' << 'dragenabled' << 'dropenabled' << 'selectfill'
+ end
+ private :__boolval_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BWidget::ListBox::Item)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ #def imagebind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ #def imagebind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ def imagebind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ end
+
+ #def textbind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ #def textbind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ def textbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ end
+
+ def delete(*args)
+ tk_send('delete', *args)
+ self
+ end
+
+ def edit(item, text, *args)
+ tk_send('edit', tagid(item), text, *args)
+ self
+ end
+
+ def exist?(item)
+ bool(tk_send('exists', tagid(item)))
+ end
+
+ def index(item)
+ num_or_str(tk_send('index', tagid(item)))
+ end
+
+ def insert(idx, item, keys={})
+ tk_send('insert', idx, tagid(item), *hash_kv(keys))
+ self
+ end
+
+ def get_item(idx)
+ tk_send('items', idx)
+ end
+
+ def items(first=None, last=None)
+ list(tk_send('items', first, last))
+ end
+
+ def move(item, idx)
+ tk_send('move', tagid(item), idx)
+ self
+ end
+
+ def reorder(neworder)
+ tk_send('reorder', neworder)
+ self
+ end
+
+ def see(item)
+ tk_send('see', tagid(item))
+ self
+ end
+
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+
+ def selection_set(*args)
+ tk_send_without_enc('selection', 'set',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_add(*args)
+ tk_send_without_enc('selection', 'add',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_remove(*args)
+ tk_send_without_enc('selection', 'remove',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_get(*args)
+ simplelist(tk_send_without_enc('selection', 'get')).collect{|item|
+ Tk::BWidget::ListBox::Item.id2obj(self, item)
+ }
+ end
+end
+
+class Tk::BWidget::ListBox::Item
+ include TkTreatTagFont
+
+ ListItem_TBL = TkCore::INTERP.create_table
+
+ (ListItem_ID = ['bw:item'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ListItem_TBL.mutex.synchronize{ ListItem_TBL.clear }
+ }
+
+ def self.id2obj(lbox, id)
+ lpath = lbox.path
+ ListItem_TBL.mutex.synchronize{
+ if ListItem_TBL[lpath]
+ ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(lbox, *args)
+ if lbox.kind_of?(Tk::BWidget::ListBox)
+ @listbox = lbox
+ else
+ fail RuntimeError,
+ "expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument"
+ end
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+
+ index = keys.delete('index')
+ unless args.empty?
+ index = args.shift
+ end
+ index = 'end' unless index
+
+ unless args.empty?
+ fail RuntimeError, 'too much arguments'
+ end
+
+ @lpath = @listbox.path
+
+ if keys.key?('itemname')
+ @path = @id = keys.delete('itemname')
+ else
+ ListItem_ID.mutex.synchronize{
+ @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
+ ListItem_ID[1].succ!
+ }
+ end
+
+ ListItem_TBL.mutex.synchronize{
+ ListItem_TBL[@id] = self
+ ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
+ ListItem_TBL[@lpath][@id] = self
+ }
+
+ @listbox.insert(index, @id, keys)
+ end
+
+ def listbox
+ @listbox
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget(key)
+ end
+
+ def []=(key, val)
+ configure(key, val)
+ val
+ end
+
+ def cget_tkstring(key)
+ @listbox.itemcget_tkstring(@id, key)
+ end
+ def cget(key)
+ @listbox.itemcget(@id, key)
+ end
+ def cget_strict(key)
+ @listbox.itemcget_strict(@id, key)
+ end
+
+ def configure(key, val=None)
+ @listbox.itemconfigure(@id, key, val)
+ end
+
+ def configinfo(key=nil)
+ @listbox.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @listbox.current_itemconfiginfo(@id, key)
+ end
+
+ def delete
+ @listbox.delete(@id)
+ self
+ end
+
+ def edit(*args)
+ @listbox.edit(@id, *args)
+ self
+ end
+
+ def exist?
+ @listbox.exist?(@id)
+ end
+
+ def index
+ @listbox.index(@id)
+ end
+
+ def move(index)
+ @listbox.move(@id, index)
+ end
+
+ def see
+ @listbox.see(@id)
+ end
+
+ def selection_add
+ @listbox.selection_add(@id)
+ end
+
+ def selection_remove
+ @listbox.selection_remove(@id)
+ end
+
+ def selection_set
+ @listbox.selection_set(@id)
+ end
+
+ def selection_toggle
+ @listbox.selection_toggle(@id)
+ end
+end
+
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb
new file mode 100644
index 0000000..92253bd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb
@@ -0,0 +1,132 @@
+#
+# tkextlib/bwidget/mainframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/progressbar'
+
+module Tk
+ module BWidget
+ class MainFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::MainFrame
+ TkCommandNames = ['MainFrame'.freeze].freeze
+ WidgetClassName = 'MainFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'progressfg'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'progressvar'
+ end
+ private :__tkvariable_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ {
+ 'menu'=>proc{|v| simplelist(v).collect!{|elem| simplelist(v)}}
+ }
+ end
+ private :__val2ruby_optkeys
+
+ def add_indicator(keys={}, &b)
+ win = window(tk_send('addindicator', *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def add_toolbar(&b)
+ win = window(tk_send('addtoolbar'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_frame(&b)
+ win = window(tk_send('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_indicator(idx, &b)
+ win = window(tk_send('getindicator', idx))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_menu(menu_id, &b)
+ win = window(tk_send('getmenu', menu_id))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_toolbar(idx, &b)
+ win = window(tk_send('gettoolbar', idx))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_menustate(tag)
+ tk_send('getmenustate', tag) # return state name string
+ end
+
+ def set_menustate(tag, state)
+ tk_send('setmenustate', tag, state)
+ self
+ end
+
+ def show_statusbar(name)
+ tk_send('showstatusbar', name)
+ self
+ end
+
+ def show_toolbar(idx, mode)
+ tk_send('showtoolbar', idx, mode)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
new file mode 100644
index 0000000..7b62614
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
@@ -0,0 +1,192 @@
+#
+# tkextlib/bwidget/messagedlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/dialog.rb'
+
+module Tk
+ module BWidget
+ class MessageDlg < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::MessageDlg
+ TkCommandNames = ['MessageDlg'.freeze].freeze
+ WidgetClassName = 'MessageDlg'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def initialize(parent=nil, keys=nil)
+ @relative = ''
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ @relative = keys['parent'] if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(keys)
+ elsif keys
+ keys = _symbolkey2str(keys)
+ @relative = keys.delete('parent') if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(parent, keys)
+ else
+ super(parent)
+ end
+ end
+
+ def create_self(keys)
+ # NOT create widget.
+ # Because the widget no longer exist when returning from creation.
+ @keys = _symbolkey2str(keys).update('parent'=>@relative)
+ @info = nil
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'message' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'buttons'
+ end
+ private :__listval_optkeys
+
+ def cget(slot)
+ slot = slot.to_s
+ if slot == 'relative'
+ slot = 'parent'
+ end
+ if winfo_exist?
+ val = super(slot)
+ @keys[slot] = val
+ end
+ @keys[slot]
+ end
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'relative'
+ slot = 'parent'
+ end
+ if winfo_exist?
+ val = super(slot)
+ @keys[slot] = val
+ end
+ @keys[slot]
+ end
+
+ def configure(slot, value=None)
+ if winfo_exist?
+ super(slot, value)
+ end
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ slot['parent'] = slot.delete('relative') if slot.key?('relative')
+ @keys.update(slot)
+
+ if @info
+ # update @info
+ slot.each{|k, v|
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = @info.assoc(k))
+ inf[-1] = v
+ else
+ @info << [k, '', '', '', v]
+ end
+ else
+ if (inf = @info[k])
+ inf[-1] = v
+ else
+ @info[k] = ['', '', '', v]
+ end
+ end
+ }
+ end
+
+ else # ! Hash
+ slot = slot.to_s
+ slot = 'parent' if slot == 'relative'
+ @keys[slot] = value
+
+ if @info
+ # update @info
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = @info.assoc(slot))
+ inf[-1] = value
+ else
+ @info << [slot, '', '', '', value]
+ end
+ else
+ if (inf = @info[slot])
+ inf[-1] = value
+ else
+ @info[slot] = ['', '', '', value]
+ end
+ end
+ end
+ end
+
+ self
+ end
+
+ def configinfo(slot=nil)
+ if winfo_exist?
+ @info = super()
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ @info << ['relative', 'parent']
+ else
+ @info['relative'] = 'parent'
+ end
+ end
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if @info
+ if winfo_exist?
+ # update @keys
+ @info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 }
+ end
+ else
+ @info = []
+ @keys.each{|k, v|
+ @info << [k, '', '', '', v]
+ }
+ @info << ['relative', 'parent']
+ end
+
+ if slot
+ @info.asoc(slot.to_s).dup
+ else
+ @info.dup
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if @info
+ if winfo_exist?
+ # update @keys
+ @info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 }
+ end
+ else
+ @info = {}
+ @keys.each{|k, v|
+ @info[k] = ['', '', '', v]
+ }
+ @info['relative'] = 'parent'
+ end
+
+ if slot
+ @info[slot.to_s].dup
+ else
+ @info.dup
+ end
+ end
+ end
+
+ def create
+ # return the index of the pressed button, or nil if it is destroyed
+ ret = num_or_str(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ (ret < 0)? nil: ret
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb
new file mode 100644
index 0000000..ed28bcd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb
@@ -0,0 +1,166 @@
+#
+# tkextlib/bwidget/notebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class NoteBook < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::NoteBook
+ include TkItemConfigMethod
+
+ TkCommandNames = ['NoteBook'.freeze].freeze
+ WidgetClassName = 'NoteBook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Event_for_Tabs < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # page idenfier
+ ]
+ end
+ end
+
+ def __boolval_optkeys
+ super() << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def tagid(id)
+ if id.kind_of?(TkWindow)
+ #id.path
+ id.epath
+ elsif id.kind_of?(TkObject)
+ id.to_eval
+ else
+ # id.to_s
+ _get_eval_string(id)
+ end
+ end
+
+ #def tabbind(*args)
+ # _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ # self
+ #end
+ def tabbind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'],
+ context, cmd, *args)
+ self
+ end
+
+ #def tabbind_append(*args)
+ # _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ # self
+ #end
+ def tabbind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'],
+ context, cmd, *args)
+ self
+ end
+
+ def tabbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ self
+ end
+
+ def tabbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ end
+
+ def add(page, &b)
+ win = window(tk_send('add', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def compute_size
+ tk_send('compute_size')
+ self
+ end
+
+ def delete(page, destroyframe=None)
+ tk_send('delete', tagid(page), destroyframe)
+ self
+ end
+
+ def get_frame(page, &b)
+ win = window(tk_send('getframe', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def index(page)
+ num_or_str(tk_send('index', tagid(page)))
+ end
+
+ def insert(index, page, keys={}, &b)
+ win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def move(page, index)
+ tk_send('move', tagid(page), index)
+ self
+ end
+
+ def get_page(page)
+ tk_send('pages', page)
+ end
+
+ def pages(first=None, last=None)
+ list(tk_send('pages', first, last))
+ end
+
+ def raise(page=nil)
+ if page
+ tk_send('raise', page)
+ self
+ else
+ tk_send('raise')
+ end
+ end
+
+ def see(page)
+ tk_send('see', page)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
new file mode 100644
index 0000000..31bbf1f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/pagesmanager.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PagesManager < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PagesManager
+ TkCommandNames = ['PagesManager'.freeze].freeze
+ WidgetClassName = 'PagesManager'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def tagid(id)
+ # id.to_s
+ _get_eval_string(id)
+ end
+
+ def add(page, &b)
+ win = window(tk_send('add', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def compute_size
+ tk_send('compute_size')
+ self
+ end
+
+ def delete(page)
+ tk_send('delete', tagid(page))
+ self
+ end
+
+ def get_frame(page, &b)
+ win = window(tk_send('getframe', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_page(page)
+ tk_send('pages', page)
+ end
+
+ def pages(first=None, last=None)
+ list(tk_send('pages', first, last))
+ end
+
+ def raise(page=None)
+ tk_send('raise', page)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
new file mode 100644
index 0000000..54cf06c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
@@ -0,0 +1,42 @@
+#
+# tkextlib/bwidget/panedwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PanedWindow < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PanedWindow
+ TkCommandNames = ['PanedWindow'.freeze].freeze
+ WidgetClassName = 'PanedWindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'activator'
+ end
+ private :__strval_optkeys
+
+ def add(keys={})
+ window(tk_send('add', *hash_kv(keys)))
+ end
+
+ def get_frame(idx, &b)
+ win = window(tk_send_without_enc('getframe', idx))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb
new file mode 100644
index 0000000..1cbf914
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb
@@ -0,0 +1,67 @@
+#
+# tkextlib/bwidget/panelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PanelFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PanelFrame
+ TkCommandNames = ['PanelFrame'.freeze].freeze
+ WidgetClassName = 'PanelFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + ['panelforeground', 'panelbackground']
+ end
+ private :__strval_optkeys
+
+ def add(win, keys={})
+ tk_send('add', win, keys)
+ self
+ end
+
+ def delete(*wins)
+ tk_send('delete', *wins)
+ self
+ end
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def items
+ simplelist(tk_send('items')).map{|w| window(w)}
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins) # same to 'remove_with_destroy'
+ tk_send('delete', *wins)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb
new file mode 100644
index 0000000..ea50c87
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb
@@ -0,0 +1,44 @@
+#
+# tkextlib/bwidget/passwddlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class PasswdDlg < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::PasswdDlg
+ TkCommandNames = ['PasswdDlg'.freeze].freeze
+ WidgetClassName = 'PasswdDlg'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'loginhelptext' << 'loginlabel' << 'logintext' <<
+ 'passwdlabel' << 'passwdtext'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'passwdeditable' << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'loginhelpvar' << 'logintextvariable' <<
+ 'passwdhelpvar' << 'passwdtextvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def create
+ login, passwd = simplelist(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ [login, passwd]
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb
new file mode 100644
index 0000000..18eb673
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/progressbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ProgressBar < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ProgressBar
+ TkCommandNames = ['ProgressBar'.freeze].freeze
+ WidgetClassName = 'ProgressBar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
new file mode 100644
index 0000000..0c0c454
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/bwidget/progressdlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/variable'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/progressbar'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class ProgressDlg < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::ProgressDlg
+ TkCommandNames = ['ProgressDlg'.freeze].freeze
+ WidgetClassName = 'ProgressDlg'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ # NOT create widget for reusing the object
+ super(keys)
+ @keys['textvariable'] = TkVariable.new unless @keys.key?('textvariable')
+ @keys['variable'] = TkVariable.new unless @keys.key?('variable')
+ end
+
+ def textvariable
+ @keys['textvariable']
+ end
+
+ def text
+ @keys['textvariable'].value
+ end
+
+ def text= (txt)
+ @keys['textvariable'].value = txt
+ end
+
+ def variable
+ @keys['variable']
+ end
+
+ def value
+ @keys['variable'].value
+ end
+
+ def value= (val)
+ @keys['variable'].value = val
+ end
+
+ def create
+ window(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
new file mode 100644
index 0000000..5bd00d6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
@@ -0,0 +1,40 @@
+#
+# tkextlib/bwidget/scrollableframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrollableFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrollableFrame
+ include Scrollable
+
+ TkCommandNames = ['ScrollableFrame'.freeze].freeze
+ WidgetClassName = 'ScrollableFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def see(win, vert=None, horiz=None)
+ tk_send_without_enc('see', win, vert, horiz)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
new file mode 100644
index 0000000..ea5a18c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
@@ -0,0 +1,48 @@
+#
+# tkextlib/bwidget/scrolledwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrolledWindow < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrolledWindow
+ TkCommandNames = ['ScrolledWindow'.freeze].freeze
+ WidgetClassName = 'ScrolledWindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'sides'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'managed'
+ end
+ private :__boolval_optkeys
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def set_widget(win)
+ tk_send_without_enc('setwidget', win)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb
new file mode 100644
index 0000000..ab27bc9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb
@@ -0,0 +1,25 @@
+#
+# tkextlib/bwidget/scrollview.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrollView < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrollView
+ TkCommandNames = ['ScrollView'.freeze].freeze
+ WidgetClassName = 'ScrollView'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'fill'
+ end
+ private :__strval_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
new file mode 100644
index 0000000..456175e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/selectcolor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class SelectColor < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectColor
+ end
+ class Menubutton < Tk::Menubutton
+ end
+ MenuButton = Menubutton
+ end
+ end
+end
+
+class Tk::BWidget::SelectColor
+ extend Tk
+
+ TkCommandNames = ['SelectColor'.freeze].freeze
+ WidgetClassName = 'SelectColor'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def dialog(keys={})
+ newkeys = @keys.dup
+ newkeys.update(_symbolkey2str(keys))
+ tk_call('SelectColor::dialog', @path, *hash_kv(newkeys))
+ end
+
+ def menu(*args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ else
+ keys = {}
+ end
+ place = args.flatten
+ newkeys = @keys.dup
+ newkeys.update(_symbolkey2str(keys))
+ tk_call('SelectColor::menu', @path, place, *hash_kv(newkeys))
+ end
+
+ def self.set_color(idx, color)
+ tk_call('SelectColor::setcolor', idx, color)
+ end
+end
+
+class Tk::BWidget::SelectColor::Dialog
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def create
+ @keys['type'] = 'dialog' # 'dialog' type returns color
+ tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectColor::Menubutton
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'menubutton' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(keys)))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb
new file mode 100644
index 0000000..23419cb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb
@@ -0,0 +1,91 @@
+#
+# tkextlib/bwidget/selectfont.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class SelectFont < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectFont
+ end
+ class Toolbar < TkWindow
+ end
+ end
+ end
+end
+
+class Tk::BWidget::SelectFont
+ extend Tk
+
+ TkCommandNames = ['SelectFont'.freeze].freeze
+ WidgetClassName = 'SelectFont'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'sampletext' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'nosizes'
+ end
+ private :__boolval_optkeys
+
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+ private :__font_optkeys
+
+ def create
+ tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+
+ def self.load_font
+ tk_call('SelectFont::loadfont')
+ end
+end
+
+class Tk::BWidget::SelectFont::Dialog
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.delete['type']
+ slot.delete[:type]
+ return self if slot.empty?
+ else
+ return self if slot == 'type' || slot == :type
+ end
+ super(slot, value)
+ end
+
+ def create
+ @keys['type'] = 'dialog' # 'dialog' type returns font name
+ tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectFont::Toolbar
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'toolbar' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectFont::TkCommandNames[0],
+ @path, *hash_kv(keys)))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb
new file mode 100644
index 0000000..6d92321
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/separator.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Separator < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::Separator
+ TkCommandNames = ['Separator'.freeze].freeze
+ WidgetClassName = 'Separator'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb
new file mode 100644
index 0000000..0a45b04
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb
@@ -0,0 +1,98 @@
+#
+# tkextlib/bwidget/entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/arrowbutton'
+require 'tkextlib/bwidget/entry'
+
+module Tk
+ module BWidget
+ class SpinBox < Tk::Entry
+ end
+ end
+end
+
+class Tk::BWidget::SpinBox
+ include Scrollable
+
+ TkCommandNames = ['SpinBox'.freeze].freeze
+ WidgetClassName = 'SpinBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext' << 'insertbackground' << 'entryfg' << 'entrybg'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled' << 'editable'
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ #def entrybind(*args)
+ # _bind([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ #def entrybind_append(*args)
+ # _bind_append([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ def entrybind_remove(*args)
+ _bind_remove([path, 'bind'], *args)
+ self
+ end
+
+ def entrybindinfo(*args)
+ _bindinfo([path, 'bind'], *args)
+ self
+ end
+
+ def get_index_of_value
+ number(tk_send_without_enc('getvalue'))
+ end
+ alias get_value get_index_of_value
+ alias get_value_index get_index_of_value
+
+ def set_value_by_index(idx)
+ idx = "@#{idx}" if idx.kind_of?(Integer)
+ tk_send_without_enc('setvalue', idx)
+ self
+ end
+ alias set_value set_value_by_index
+ alias set_index_value set_value_by_index
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb
new file mode 100644
index 0000000..5c5dd43
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/bwidget/statusbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class StatusBar < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::StatusBar
+ TkCommandNames = ['StatusBar'.freeze].freeze
+ WidgetClassName = 'StatusBar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'showresize' << 'showseparator' << 'showresizesep'
+ end
+ private :__boolval_optkeys
+
+ def add(win, keys={})
+ tk_send('add', win, keys)
+ self
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins) # same to 'remove_with_destroy'
+ tk_send('delete', *wins)
+ self
+ end
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def items
+ simplelist(tk_send('items')).map{|w| window(w)}
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb
new file mode 100644
index 0000000..7187911
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/bwidget/titleframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class TitleFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::TitleFrame
+ TkCommandNames = ['TitleFrame'.freeze].freeze
+ WidgetClassName = 'TitleFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb
new file mode 100644
index 0000000..089c482
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb
@@ -0,0 +1,500 @@
+#
+# tkextlib/bwidget/tree.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Tree < TkWindow
+ class Node < TkObject
+ end
+ end
+ end
+end
+
+class Tk::BWidget::Tree
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['Tree'.freeze].freeze
+ WidgetClassName = 'Tree'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Event_for_Items < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # item idenfier
+ ]
+ end
+ end
+
+ def __strval_optkeys
+ super() << 'crossfill' << 'linesfill'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled' <<
+ 'redraw' << 'selectfill' << 'showlines'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BWidget::Tree::Node)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ def areabind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindArea'],
+ context, cmd, *args)
+ self
+ end
+
+ def areabind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindArea'],
+ context, cmd, *args)
+ self
+ end
+
+ def areabind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindArea'], *args)
+ self
+ end
+
+ def areabindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindArea'], *args)
+ end
+
+ #def imagebind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ #def imagebind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ def imagebind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ end
+
+ #def textbind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ #def textbind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ def textbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ end
+
+ def close_tree(node, recurse=None)
+ tk_send('closetree', tagid(node), recurse)
+ self
+ end
+
+ def delete(*args)
+ tk_send('delete', *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def edit(node, text, *args)
+ tk_send('edit', tagid(node), text, *args)
+ self
+ end
+
+ def exist?(node)
+ bool(tk_send('exists', tagid(node)))
+ end
+
+ def find(findinfo, confine=None)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send(findinfo, confine))
+ end
+ def find_position(x, y, confine=None)
+ self.find(_at(x,y), confine)
+ end
+ def find_line(linenum)
+ self.find(linenum)
+ end
+
+ def index(node)
+ num_or_str(tk_send('index', tagid(node)))
+ end
+
+ def insert(idx, parent, node, keys={})
+ tk_send('insert', idx, tagid(parent), tagid(node), *hash_kv(keys))
+ self
+ end
+
+ def line(node)
+ number(tk_send('line', tagid(node)))
+ end
+
+ def move(parent, node, idx)
+ tk_send('move', tagid(parent), tagid(node), idx)
+ self
+ end
+
+ def get_node(node, idx)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send('nodes', tagid(node), idx))
+ end
+
+ def nodes(node, first=None, last=None)
+ simplelist(tk_send('nodes', tagid(node), first, last)).collect{|node|
+ Tk::BWidget::Tree::Node.id2obj(self, node)
+ }
+ end
+
+ def open?(node)
+ bool(self.itemcget(tagid(node), 'open'))
+ end
+
+ def open_tree(node, recurse=None)
+ tk_send('opentree', tagid(node), recurse)
+ self
+ end
+
+ def parent(node)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send('parent', tagid(node)))
+ end
+
+ def reorder(node, neworder)
+ tk_send('reorder', tagid(node), neworder)
+ self
+ end
+
+ def see(node)
+ tk_send('see', tagid(node))
+ self
+ end
+
+ def selection_add(*args)
+ tk_send_without_enc('selection', 'add',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+
+ def selection_get
+ list(tk_send_without_enc('selection', 'get'))
+ end
+
+ def selection_include?(*args)
+ bool(tk_send_without_enc('selection', 'get',
+ *(args.collect{|node| tagid(node)})))
+ end
+
+ def selection_range(*args)
+ tk_send_without_enc('selection', 'range',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_remove(*args)
+ tk_send_without_enc('selection', 'remove',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_set(*args)
+ tk_send_without_enc('selection', 'set',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_toggle(*args)
+ tk_send_without_enc('selection', 'toggle',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def toggle(node)
+ tk_send_without_enc('toggle', tagid(node))
+ self
+ end
+
+ def visible(node)
+ bool(tk_send_without_enc('visible', tagid(node)))
+ end
+end
+
+class Tk::BWidget::Tree::Node
+ include TkTreatTagFont
+
+ TreeNode_TBL = TkCore::INTERP.create_table
+
+ (TreeNode_ID = ['bw:node'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNode_TBL.mutex.synchronize{ TreeNode_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeNode_TBL.mutex.synchronize{
+ if TreeNode_TBL[tpath]
+ TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(tree, *args)
+ if tree.kind_of?(Tk::BWidget::Tree)
+ @tree = tree
+ parent = args.shift
+ if parent.kind_of?(Tk::BWidget::Tree::Node)
+ if parent.tree.path != @tree.path
+ fail RuntimeError, 'tree of parent node is not match'
+ end
+ end
+ elsif tree.kind_of?(Tk::BWidget::Tree::Node)
+ @tree = tree.tree
+ parent = tree.parent
+ else
+ fail RuntimeError,
+ "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
+ end
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+
+ index = keys.delete('index')
+ unless args.empty?
+ index = args.shift
+ end
+ index = 'end' unless index
+
+ unless args.empty?
+ fail RuntimeError, 'too much arguments'
+ end
+
+ @tpath = @tree.path
+
+ if keys.key?('nodename')
+ @path = @id = keys.delete('nodename')
+ else
+ TreeNode_ID.mutex.synchronize{
+ @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
+ TreeNode_ID[1].succ!
+ }
+ end
+
+ TreeNode_TBL.mutex.synchronize{
+ TreeNode_TBL[@id] = self
+ TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
+ TreeNode_TBL[@tpath][@id] = self
+ }
+
+ @tree.insert(index, parent, @id, keys)
+ end
+
+ def tree
+ @tree
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget(key)
+ end
+
+ def []=(key, val)
+ configure(key, val)
+ val
+ end
+
+ def cget_tkstring(key)
+ @tree.itemcget_tkstring(@id, key)
+ end
+ def cget(key)
+ @tree.itemcget(@id, key)
+ end
+ def cget_strict(key)
+ @tree.itemcget_strict(@id, key)
+ end
+
+ def configure(key, val=None)
+ @tree.itemconfigure(@id, key, val)
+ end
+
+ def configinfo(key=nil)
+ @tree.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @tree.current_itemconfiginfo(@id, key)
+ end
+
+ def close_tree(recurse=None)
+ @tree.close_tree(@id, recurse)
+ self
+ end
+
+ def delete
+ @tree.delete(@id)
+ self
+ end
+
+ def edit(*args)
+ @tree.edit(@id, *args)
+ self
+ end
+
+ def exist?
+ @tree.exist?(@id)
+ end
+
+ def index
+ @tree.index(@id)
+ end
+
+ def move(index, parent=nil)
+ if parent
+ @tree.move(parent, @id, index)
+ else
+ @tree.move(self.parent, @id, index)
+ end
+ end
+
+ def open_tree(recurse=None)
+ @tree.open_tree(@id, recurse)
+ self
+ end
+
+ def open?
+ bool(@tree.itemcget(@id, 'open'))
+ end
+
+ def parent
+ @tree.parent(@id)
+ end
+
+ def reorder(neworder)
+ @tree.reorder(@id, neworder)
+ end
+
+ def see
+ @tree.see(@id)
+ end
+
+ def selection_add
+ @tree.selection_add(@id)
+ end
+
+ def selection_remove
+ @tree.selection_remove(@id)
+ end
+
+ def selection_set
+ @tree.selection_set(@id)
+ end
+
+ def selection_toggle
+ @tree.selection_toggle(@id)
+ end
+
+ def toggle
+ @tree.toggle(@id)
+ end
+
+ def visible
+ @tree.visible(@id)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb
new file mode 100644
index 0000000..a93364b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb
@@ -0,0 +1,129 @@
+#
+# tkextlib/bwidget/widget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module Widget
+ end
+ end
+end
+
+module Tk::BWidget::Widget
+ include Tk
+ extend Tk
+
+ def self.__pathname
+ 'Widget::configure'
+ end
+
+ def self.__cget_cmd
+ ['Widget::cget']
+ end
+
+ def self.__config_cmd
+ ['Widget::configure']
+ end
+
+ def self.cget_strict(slot)
+ slot = slot.to_s
+ info = {}
+ self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
+ fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
+ info.values[0]
+ end
+ def self.cget(slot)
+ self.current_configinfo(slot).values[0]
+ end
+
+ def self.add_map(klass, subclass, subpath, opts)
+ tk_call('Widget::addmap', klass, subclass, subpath, opts)
+ end
+
+ def self.bwinclude(klass, subclass, subpath, *args)
+ tk_call('Widget::bwinclude', klass, subclass, subpath, *args)
+ end
+
+ def self.create(klass, path, rename=None, &b)
+ win = window(tk_call('Widget::create', klass, path, rename))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def self.declare(klass, optlist)
+ tk_call('Widget::declare', klass, optlist)
+ end
+
+ def self.define(klass, filename, *args)
+ tk_call('Widget::define', klass, filename, *args)
+ end
+
+ def self.destroy(win)
+ tk_call('Widget::destroy', _epath(win))
+ end
+
+ def self.focus_next(win)
+ tk_call('Widget::focusNext', win)
+ end
+
+ def self.focus_ok(win)
+ tk_call('Widget::focusOk', win)
+ end
+
+ def self.focus_prev(win)
+ tk_call('Widget::focusPrev', win)
+ end
+
+ def self.generate_doc(dir, widgetlist)
+ tk_call('Widget::generate-doc', dir, widgetlist)
+ end
+
+ def self.generate_widget_doc(klass, iscmd, file)
+ tk_call('Widget::generate-widget-doc', klass, iscmd, file)
+ end
+
+ def self.get_option(win, option)
+ tk_call('Widget::getoption', win, option)
+ end
+
+ def self.get_variable(win, varname, my_varname=None)
+ tk_call('Widget::getVariable', win, varname, my_varname)
+ end
+
+ def self.has_changed(win, option, pvalue)
+ tk_call('Widget::hasChanged', win, option, pvalue)
+ end
+
+ def self.init(klass, win, options)
+ tk_call('Widget::init', klass, win, options)
+ end
+
+ def self.set_option(win, option, value)
+ tk_call('Widget::setoption', win, option, value)
+ end
+
+ def self.sub_cget_strict(win, subwidget)
+ tk_call('Widget::subcget', win, subwidget)
+ end
+ def self.sub_cget(win, subwidget)
+ self.sub_cget_strict(win, subwidget)
+ end
+
+ def self.sync_options(klass, subclass, subpath, options)
+ tk_call('Widget::syncoptions', klass, subclass, subpath, options)
+ end
+
+ def self.tkinclude(klass, tkwidget, subpath, *args)
+ tk_call('Widget::tkinclude', klass, tkwidget, subpath, *args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itcl.rb b/jni/ruby/ext/tk/lib/tkextlib/itcl.rb
new file mode 100644
index 0000000..1d6ecf0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itcl.rb
@@ -0,0 +1,13 @@
+#
+# [incr Tcl] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/itcl/setup.rb'
+
+# load library
+require 'tkextlib/itcl/incr_tcl.rb'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
new file mode 100644
index 0000000..8f6bb33
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
@@ -0,0 +1,178 @@
+#
+# tkextlib/itk/incr_tcl.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script
+require 'tkextlib/itcl.rb'
+
+# TkPackage.require('Itcl', '3.2')
+TkPackage.require('Itcl')
+
+module Tk
+ module Itcl
+ include Tk
+ extend Tk
+
+ LIBRARY = TkVarAccess.new('::itcl::library')
+ PURIST = TkVarAccess.new('::itcl::purist')
+
+ VERSION = TkCore::INTERP._invoke("set", "::itcl::version").freeze
+ PATCHLEVEL = TkCore::INTERP._invoke("set", "::itcl::patchLevel").freeze
+
+ PACKAGE_NAME = 'Itcl'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Itcl')
+ rescue
+ ''
+ end
+ end
+
+ ##############################################
+
+ class ItclObject < TkObject
+ ITCL_CLASSNAME = ''.freeze
+
+ (ITCL_OBJ_ID = ['itclobj'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ ITCL_OBJ_TBL = TkUtil.untrust({})
+
+ def initialize(*args)
+ if (@klass = self.class::ITCL_CLASSNAME).empty?
+ fail RuntimeError, 'unknown itcl class (abstract class?)'
+ end
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID.mutex.synchronize{
+ @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
+ }
+ @path = @id
+ end
+
+ def self.call_proc(name, *args)
+ tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args)
+ end
+
+ def call_method(name, *args)
+ tk_call(@path, name, *args)
+ end
+
+ def isa(klass)
+ bool(tk_call(@path, 'isa', klass))
+ end
+ alias itcl_kind_of? isa
+
+ def info_class
+ tk_call(@path, 'info', 'class')
+ end
+
+ def info_inherit
+ simplelist(tk_call(@path, 'info', 'inherit'))
+ end
+
+ def info_heritage
+ list(tk_call(@path, 'info', 'heritage'))
+ end
+
+ def info_function(*args)
+ if args[-1].kind_of?(Array)
+ params = args.pop
+ params.each{|param|
+ param = param.to_s
+ args << ( (param[0] == ?-)? param: "-#{param}" )
+ }
+ end
+ list(tk_call(@path, 'info', 'function', *args))
+ end
+
+ def info_variable(*args)
+ if args[-1].kind_of?(Array)
+ params = args.pop
+ params.each{|param|
+ param = param.to_s
+ args << ( (param[0] == ?-)? param: "-#{param}" )
+ }
+ end
+ list(tk_call(@path, 'info', 'variable', *args))
+ end
+ end
+
+ ##############################################
+
+ def self.body(klass, func, args, body)
+ tk_call('::itcl::body', "#{klass}::#{func}", args, body)
+ end
+
+ def self.code(cmd, *args)
+ tk_call('::itcl::code', cmd, *args)
+ end
+
+ def self.code_in_namespace(namespace, cmd, *args)
+ tk_call('::itcl::code', '-namespace', namespace, cmd, *args)
+ end
+
+ def self.configbody(klass, var, body)
+ tk_call('::itcl::configbody', "#{klass}::#{var}", body)
+ end
+
+ def self.create_itcl_class(name, body)
+ TkCore::INTERP._invoke('::itcl::class', name, body)
+ klass = Class.new(Tk::Itcl::ItclObject)
+ klass.const_set('ITCL_CLASSNAME', name.dup.freeze)
+ klass
+ end
+
+ def self.delete_itcl_class(*names)
+ tk_call('::itcl::delete', 'class', *names)
+ end
+
+ def self.delete_itcl_object(*names)
+ tk_call('::itcl::delete', 'object', *names)
+ end
+
+ def self.delete_namespace(*names)
+ tk_call('::itcl::delete', 'namespace', *names)
+ end
+
+ def self.ensemble(name, *args)
+ tk_call('::itcl::ensemble', name, *args)
+ end
+
+ def self.find_classes(pat=None)
+ simplelist(tk_call('::itcl::find', 'classes', pat))
+ end
+
+ def self.find_objects(*args)
+ simplelist(tk_call('::itcl::find', 'objects', *args))
+ end
+
+ def self.is_itcl_class(target)
+ bool(tk_call('::itcl::is', 'class', target))
+ end
+
+ def self.is_itcl_object(target)
+ bool(tk_call('::itcl::is', 'object', target))
+ end
+
+ def self.create_local_obj(klass, name, *args)
+ tk_call('::itcl::local', klass, name, *args)
+ end
+
+ def self.is_itcl_instance(klass, target)
+ bool(tk_call('::itcl::is', 'object', '-class', klass, target))
+ end
+
+ def self.scope(var)
+ tk_call('::itcl::scope', var)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb
new file mode 100644
index 0000000..70b38e4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb
@@ -0,0 +1,13 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
+
+
+# set [incr Tcl] library directory
+
+# ENV['ITCL_LIBRARY'] = '/usr/local/ActiveTcl/lib/itcl3.2/'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itk.rb b/jni/ruby/ext/tk/lib/tkextlib/itk.rb
new file mode 100644
index 0000000..7492bd3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itk.rb
@@ -0,0 +1,13 @@
+#
+# [incr Tk] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/itk/setup.rb'
+
+# load library
+require 'tkextlib/itk/incr_tk.rb'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb b/jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb
new file mode 100644
index 0000000..989585e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb
@@ -0,0 +1,446 @@
+#
+# tkextlib/itk/incr_tk.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/menuspec'
+require 'tkextlib/itcl.rb'
+
+# call setup script
+require 'tkextlib/itk.rb'
+
+#TkPackage.require('Itk', '3.2')
+TkPackage.require('Itk')
+
+module Tk
+ module Itk
+ include Tk
+ extend Tk
+
+ LIBRARY = TkVarAccess.new('::itk::library')
+
+ PACKAGE_NAME = 'Itk'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Itk')
+ rescue
+ ''
+ end
+ end
+
+ def self.usual(arg, *args)
+ tk_call('::itk::usual', arg, *args)
+ end
+
+ def self.usual_names
+ list(tk_call('::itk::usual'))
+ end
+
+ ############################
+
+ class Archetype < TkWindow
+ TkCommandNames = [].freeze
+ # WidgetClassName = 'Archetype'.freeze
+ # WidgetClassNames[WidgetClassName] = self
+
+ def self.to_eval
+ '::itk::' << self::WidgetClassName
+ end
+
+ def __destroy_hook__
+ Tk::Itk::Component::ComponentID_TBL.delete(self.path)
+ end
+
+ #### [incr Tk] public methods
+ def component
+ simplelist(tk_send('component'))
+ end
+
+ def component_path(name)
+ window(tk_send('component', name))
+ end
+ alias component_widget component_path
+
+ def component_invoke(name, cmd, *args)
+ window(tk_send('component', name, cmd, *args))
+ end
+
+ def component_obj(*names)
+ names = component if names.empty?
+ names.collect{|name| Tk::Itk::Component.new(self.path, name) }
+ end
+
+ #### [incr Tk] protected methods
+=begin
+ def itk_component_add(visibility, name, create_cmds, option_cmds=None)
+ args = []
+ visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )}
+ args << '--' << name << create_cmd << option_cmds
+ tk_call('itk_component', 'add', *args)
+ end
+
+ def itk_component_delete(*names)
+ tk_call('itk_component', 'delete', *names)
+ end
+
+ def itk_initialize(keys={})
+ tk_call('itk_initialize', keys)
+ end
+
+ def itk_option_add(*args)
+ tk_call('itk_option', 'add', *args)
+ end
+
+ def itk_option_define(name, resource, klass, init, config=None)
+ tk_call('itk_option', 'define', name, resource, klass, init, config)
+ end
+
+ def itk_option_remove(*args)
+ tk_call('itk_option', 'remove', *args)
+ end
+=end
+ end
+
+ ############################
+
+ class Toplevel < Archetype
+ TkCommandNames = ['::itk::Toplevel'].freeze
+ WidgetClassName = 'Toplevel'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include Wm
+ include TkMenuSpec
+
+ def __strval_optkeys
+ super() << 'title'
+ end
+ private :__strval_optkeys
+ end
+
+ ############################
+
+ class Widget < Archetype
+ TkCommandNames = ['::itk::Widget'].freeze
+ WidgetClassName = 'Widget'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ end
+
+
+ ############################
+
+ class Component < TkObject
+ def __cget_cmd
+ [self.master, 'component', self.name, 'cget']
+ end
+ private :__cget_cmd
+
+ def __config_cmd
+ [self.master, 'component', self.name, 'configure']
+ end
+ private :__config_cmd
+
+ ComponentID_TBL = TkCore::INTERP.create_table
+
+ (Itk_Component_ID = ['itk:component'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ComponentID_TBL.mutex.synchronize{ ComponentID_TBL.clear }
+ }
+
+ def self.id2obj(master, id)
+ if master.kind_of?(TkObject)
+ master = master.path
+ else
+ master = master.to_s
+ end
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(master, component=nil)
+ if master.kind_of?(TkObject)
+ master = master.path
+ else
+ master = master.to_s
+ end
+
+ if component.kind_of?(Tk::Itk::Component)
+ component = component.name
+ elsif component
+ component = component.to_s
+ else
+ Itk_Component_ID.mutex.synchronize{
+ component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
+ Itk_Component_ID[1].succ!
+ }
+ end
+
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ if ComponentID_TBL[master].key?(component)
+ return ComponentID_TBL[master][component]
+ end
+ else
+ ComponentID_TBL[master] = {}
+ end
+ }
+
+ super(master, component)
+ end
+
+ def initialize(master, component)
+ @master = master
+ @component = component
+
+ ComponentID_TBL.mutex.synchronize{
+ ComponentID_TBL[@master][@component] = self
+ }
+
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ @widget = nil
+ @path = nil
+ end
+ end
+
+ def path
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @path
+ end
+
+ def epath
+ path()
+ end
+
+ def to_eval
+ path()
+ end
+
+ def master
+ @master
+ end
+
+ def name
+ @component
+ end
+
+ def widget
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget
+ end
+
+ def widget_class
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ @widget.classname
+ rescue
+ nil
+ end
+ end
+ end
+
+ def method_missing(id, *args)
+ name = id.id2name
+
+ # try 1 : component command
+ begin
+ return tk_call(@master, 'component', @component, name, *args)
+ rescue
+ end
+
+ # try 2 : component configure
+ len = args.length
+ begin
+ case len
+ when 1
+ if name[-1] == ?=
+ return configure(name[0..-2], args[0])
+ else
+ return configure(name, args[0])
+ end
+ when 0
+ return cget(name)
+ end
+ rescue
+ end
+
+ # try 3 : widget method or widget configure
+ begin
+ unless @widget
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ end
+ @widget.__send__(id, *args)
+ rescue
+ end
+
+ # unknown method
+ super(id, *args)
+ # fail RuntimeError, "unknown method '#{name}' for #{self.inspect}"
+ end
+
+ def tk_send(cmd, *rest)
+ begin
+ tk_call(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call(@path, cmd, *rest)
+ end
+ end
+
+ def tk_send_without_enc(cmd, *rest)
+ begin
+ tk_call_without_enc(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call_without_enc(@path, cmd, *rest)
+ end
+ end
+
+ def tk_send_with_enc(cmd, *rest)
+ begin
+ tk_call_with_enc(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call_with_enc(@path, cmd, *rest)
+ end
+ end
+
+ #def bind(*args)
+ # unless @widget
+ # begin
+ # @widget = window(tk_call(@master, 'component', @component))
+ # @path = @widget.path
+ # rescue
+ # fail RuntimeError, 'component is not assigned to a widget'
+ # end
+ # end
+ # @widget.bind(*args)
+ #end
+ def bind(context, *args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @widget.bind(context, cmd, *args)
+ end
+
+ #def bind_append(*args)
+ # unless @widget
+ # begin
+ # @widget = window(tk_call(@master, 'component', @component))
+ # @path = @widget.path
+ # rescue
+ # fail RuntimeError, 'component is not assigned to a widget'
+ # end
+ # end
+ # @widget.bind_append(*args)
+ #end
+ def bind_append(context, *args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @widget.bind_append(context, cmd, *args)
+ end
+
+ def bind_remove(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bind_remove(*args)
+ end
+
+ def bindinfo(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bindinfo(*args)
+ end
+
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb
new file mode 100644
index 0000000..544926e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb
@@ -0,0 +1,13 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
+
+
+# set [incr Tk] library directory
+
+# ENV['ITK_LIBRARY'] = '/usr/local/ActiveTcl/lib/itk3.2/'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb
new file mode 100644
index 0000000..ebd4cf7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb
@@ -0,0 +1,94 @@
+#
+# [incr Widgets] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/itcl'
+require 'tkextlib/itk'
+
+# call setup script for general 'tkextlib' libraries
+#require 'tkextlib/setup.rb'
+
+# call setup script
+#require 'tkextlib/iwidgets/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('Iwidgets', '4.0')
+TkPackage.require('Iwidgets')
+
+module Tk
+ module Iwidgets
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ extend TkCore
+
+ PACKAGE_NAME = 'Iwidgets'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Iwidgets')
+ rescue
+ ''
+ end
+ end
+
+ ####################################################
+
+ autoload :Buttonbox, 'tkextlib/iwidgets/buttonbox'
+ autoload :Calendar, 'tkextlib/iwidgets/calendar'
+ autoload :Canvasprintbox, 'tkextlib/iwidgets/canvasprintbox'
+ autoload :Canvasprintdialog, 'tkextlib/iwidgets/canvasprintdialog'
+ autoload :Checkbox, 'tkextlib/iwidgets/checkbox'
+ autoload :Combobox, 'tkextlib/iwidgets/combobox'
+ autoload :Dateentry, 'tkextlib/iwidgets/dateentry'
+ autoload :Datefield, 'tkextlib/iwidgets/datefield'
+ autoload :Dialog, 'tkextlib/iwidgets/dialog'
+ autoload :Dialogshell, 'tkextlib/iwidgets/dialogshell'
+ autoload :Disjointlistbox, 'tkextlib/iwidgets/disjointlistbox'
+ autoload :Entryfield, 'tkextlib/iwidgets/entryfield'
+ autoload :Extbutton, 'tkextlib/iwidgets/extbutton'
+ autoload :Extfileselectionbox, 'tkextlib/iwidgets/extfileselectionbox'
+ autoload :Extfileselectiondialog,'tkextlib/iwidgets/extfileselectiondialog'
+ autoload :Feedback, 'tkextlib/iwidgets/feedback'
+ autoload :Fileselectionbox, 'tkextlib/iwidgets/fileselectionbox'
+ autoload :Fileselectiondialog, 'tkextlib/iwidgets/fileselectiondialog'
+ autoload :Finddialog, 'tkextlib/iwidgets/finddialog'
+ autoload :Hierarchy, 'tkextlib/iwidgets/hierarchy'
+ autoload :Hyperhelp, 'tkextlib/iwidgets/hyperhelp'
+ autoload :Labeledframe, 'tkextlib/iwidgets/labeledframe'
+ autoload :Labeledwidget, 'tkextlib/iwidgets/labeledwidget'
+ autoload :Mainwindow, 'tkextlib/iwidgets/mainwindow'
+ autoload :Menubar, 'tkextlib/iwidgets/menubar'
+ autoload :Messagebox, 'tkextlib/iwidgets/messagebox'
+ autoload :Messagedialog, 'tkextlib/iwidgets/messagedialog'
+ autoload :Notebook, 'tkextlib/iwidgets/notebook'
+ autoload :Optionmenu, 'tkextlib/iwidgets/optionmenu'
+ autoload :Panedwindow, 'tkextlib/iwidgets/panedwindow'
+ autoload :Pushbutton, 'tkextlib/iwidgets/pushbutton'
+ autoload :Promptdialog, 'tkextlib/iwidgets/promptdialog'
+ autoload :Radiobox, 'tkextlib/iwidgets/radiobox'
+ autoload :Scrolledcanvas, 'tkextlib/iwidgets/scrolledcanvas'
+ autoload :Scrolledframe, 'tkextlib/iwidgets/scrolledframe'
+ autoload :Scrolledhtml, 'tkextlib/iwidgets/scrolledhtml'
+ autoload :Scrolledlistbox, 'tkextlib/iwidgets/scrolledlistbox'
+ autoload :Scrolledtext, 'tkextlib/iwidgets/scrolledtext'
+ autoload :Scrolledwidget, 'tkextlib/iwidgets/scrolledwidget'
+ autoload :Selectionbox, 'tkextlib/iwidgets/selectionbox'
+ autoload :Selectiondialog, 'tkextlib/iwidgets/selectiondialog'
+ autoload :Shell, 'tkextlib/iwidgets/shell'
+ autoload :Spindate, 'tkextlib/iwidgets/spindate'
+ autoload :Spinint, 'tkextlib/iwidgets/spinint'
+ autoload :Spinner, 'tkextlib/iwidgets/spinner'
+ autoload :Spintime, 'tkextlib/iwidgets/spintime'
+ autoload :Tabnotebook, 'tkextlib/iwidgets/tabnotebook'
+ autoload :Tabset, 'tkextlib/iwidgets/tabset'
+ autoload :Timeentry, 'tkextlib/iwidgets/timeentry'
+ autoload :Timefield, 'tkextlib/iwidgets/timefield'
+ autoload :Toolbar, 'tkextlib/iwidgets/toolbar'
+ autoload :Watch, 'tkextlib/iwidgets/watch'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
new file mode 100644
index 0000000..91e06d1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
@@ -0,0 +1,121 @@
+#
+# tkextlib/iwidgets/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Buttonbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Buttonbox
+ TkCommandNames = ['::iwidgets::buttonbox'.freeze].freeze
+ WidgetClassName = 'Buttonbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def default(idx)
+ tk_call(@path, 'default', index(idx))
+ self
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb
new file mode 100644
index 0000000..a5478c7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb
@@ -0,0 +1,125 @@
+#
+# tkextlib/iwidgets/calendar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Calendar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Calendar
+ TkCommandNames = ['::iwidgets::calendar'.freeze].freeze
+ WidgetClassName = 'Calendar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'buttonforeground', 'outline', 'selectcolor',
+ 'weekdaybackground', 'weekendbackground'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'days'
+ end
+ private :__listval_optkeys
+
+ def __font_optkeys
+ super() + ['currentdatefont', 'datefont', 'dayfont', 'titlefont']
+ end
+ private :__font_optkeys
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class CalendarCommand < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [ [?d, ?s, :date], nil ]
+ PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['command']
+ end
+
+ #def initialize(cmd = Proc.new, *args)
+ # _initialize_for_cb_class(CalCmdArgs, cmd, *args)
+ #end
+ end
+
+ def __validation_class_list
+ super() << CalendarCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, CalendarCommand)
+=begin
+ def command(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(CalendarCommand)
+ configure('command', cmd)
+ elsif args
+ configure('command', [cmd, args])
+ else
+ configure('command', cmd)
+ end
+ end
+=end
+
+ ####################################
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def select(date)
+ tk_call(@path, 'select', date)
+ self
+ end
+
+ def show(date)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
new file mode 100644
index 0000000..398eec3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
@@ -0,0 +1,53 @@
+#
+# tkextlib/iwidgets/canvasprintbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Canvasprintbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Canvasprintbox
+ TkCommandNames = ['::iwidgets::canvasprintbox'.freeze].freeze
+ WidgetClassName = 'Canvasprintbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'filename'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'stretch'
+ end
+ private :__boolval_optkeys
+
+ def get_output
+ tk_call(@path, 'getoutput')
+ end
+
+ def print
+ bool(tk_call(@path, 'print'))
+ end
+
+ def refresh
+ tk_call(@path, 'refresh')
+ self
+ end
+
+ def set_canvas(win)
+ tk_call(@path, 'setcanvas', win)
+ self
+ end
+
+ def stop
+ tk_call(@path, 'stop')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
new file mode 100644
index 0000000..e64d815
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/canvasprintdialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Canvasprintdialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Canvasprintdialog
+ TkCommandNames = ['::iwidgets::canvasprintdialog'.freeze].freeze
+ WidgetClassName = 'Canvasprintdialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def get_output
+ tk_call(@path, 'getoutput')
+ end
+
+ def print
+ bool(tk_call(@path, 'print'))
+ end
+
+ def refresh
+ tk_call(@path, 'refresh')
+ self
+ end
+
+ def set_canvas(win)
+ tk_call(@path, 'setcanvas', win)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
new file mode 100644
index 0000000..a7476c8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -0,0 +1,130 @@
+#
+# tkextlib/iwidgets/checkbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Checkbox < Tk::Iwidgets::Labeledframe
+ end
+ end
+end
+
+class Tk::Iwidgets::Checkbox
+ TkCommandNames = ['::iwidgets::checkbox'.freeze].freeze
+ WidgetClassName = 'Checkbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def deselect(idx)
+ tk_call(@path, 'deselect', index(idx))
+ self
+ end
+
+ def flash(idx)
+ tk_call(@path, 'flash', index(idx))
+ self
+ end
+
+ def get_tags
+ simplelist(tk_call_without_enc(@path, 'get'))
+ end
+
+ def get_objs
+ simplelist(tk_call_without_enc(@path, 'get')).collect{|id|
+ Tk::Itk::Component.id2obj(self, id)
+ }
+ end
+
+ def get(idx=nil)
+ if idx
+ bool(tk_call_without_enc(@path, 'get', index(idx)))
+ else
+ get_tags
+ end
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb
new file mode 100644
index 0000000..82dcf25
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb
@@ -0,0 +1,104 @@
+#
+# tkextlib/iwidgets/combobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Combobox < Tk::Iwidgets::Entryfield
+ end
+ end
+end
+
+class Tk::Iwidgets::Combobox
+ TkCommandNames = ['::iwidgets::combobox'.freeze].freeze
+ WidgetClassName = 'Combobox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'completion' << 'dropdown' << 'editable' << 'unique'
+ end
+ private :__boolval_optkeys
+
+ def clear(component=None)
+ tk_call(@path, 'clear', component)
+ self
+ end
+
+ def delete_list(first, last=None)
+ tk_call(@path, 'delete', 'list', first, last)
+ self
+ end
+
+ def delete_entry(first, last=None)
+ tk_call(@path, 'delete', 'entry', first, last)
+ self
+ end
+
+ def get_list_contents(index)
+ tk_call(@path, 'get', index)
+ end
+
+ def insert_list(idx, *elems)
+ tk_call(@path, 'insert', 'list', idx, *elems)
+ self
+ end
+
+ def insert_entry(idx, *elems)
+ tk_call(@path, 'insert', 'entry', idx, *elems)
+ self
+ end
+
+ # listbox methods
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ # scrolledlistbox methods
+ def get_curselection
+ tk_call(@path, 'getcurselection')
+ end
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb
new file mode 100644
index 0000000..98a0051
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/dateentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dateentry < Tk::Iwidgets::Datefield
+ end
+ end
+end
+
+class Tk::Iwidgets::Dateentry
+ TkCommandNames = ['::iwidgets::dateentry'.freeze].freeze
+ WidgetClassName = 'Dateentry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb
new file mode 100644
index 0000000..50d5405
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/iwidgets/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Datefield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Datefield
+ TkCommandNames = ['::iwidgets::datefield'.freeze].freeze
+ WidgetClassName = 'Datefield'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'gmt'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def valid?
+ bool(tk_call(@path, 'isvalid'))
+ end
+ alias isvalid? valid?
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb
new file mode 100644
index 0000000..2d554ca
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dialog < Tk::Iwidgets::Dialogshell
+ end
+ end
+end
+
+class Tk::Iwidgets::Dialog
+ TkCommandNames = ['::iwidgets::dialog'.freeze].freeze
+ WidgetClassName = 'Dialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
new file mode 100644
index 0000000..e880594
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
@@ -0,0 +1,121 @@
+#
+# tkextlib/iwidgets/dialogshell.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dialogshell < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Dialogshell
+ TkCommandNames = ['::iwidgets::dialogshell'.freeze].freeze
+ WidgetClassName = 'Dialogshell'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def default(idx)
+ tk_call(@path, 'default', index(idx))
+ self
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
new file mode 100644
index 0000000..07ab025
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
@@ -0,0 +1,50 @@
+#
+# tkextlib/iwidgets/disjointlistbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Disjointlistbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Disjointlistbox
+ TkCommandNames = ['::iwidgets::disjointlistbox'.freeze].freeze
+ WidgetClassName = 'Disjointlistbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'lhslabeltext' << 'rhslabeltext' << 'lhsbuttonlabel' << 'rhsbuttonlabel'
+ end
+ private :__strval_optkeys
+
+ def set_lhs(*items)
+ tk_call(@path, 'setlhs', items)
+ self
+ end
+ def set_rhs(*items)
+ tk_call(@path, 'setrhs', items)
+ self
+ end
+
+ def get_lhs
+ simplelist(tk_call(@path, 'getlhs'))
+ end
+ def get_rhs
+ simplelist(tk_call(@path, 'getrhs'))
+ end
+
+ def insert_lhs(*items)
+ tk_call(@path, 'insertlhs', items)
+ self
+ end
+ def insert_rhs(*items)
+ tk_call(@path, 'insertrhs', items)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
new file mode 100644
index 0000000..3e7149a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
@@ -0,0 +1,185 @@
+#
+# tkextlib/iwidgets/entryfield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Entryfield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Entryfield
+ TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze
+ WidgetClassName = 'Entryfield'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class EntryfieldValidate < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?s, :char ],
+ [ ?P, ?s, :post ],
+ [ ?S, ?s, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['validate', 'invalid']
+ end
+ end
+
+ def __validation_class_list
+ super() << EntryfieldValidate
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
+=begin
+ def validate(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('validate', cmd)
+ elsif args
+ configure('validate', [cmd, args])
+ else
+ configure('validate', cmd)
+ end
+ end
+
+ def invalid(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('invalid', cmd)
+ elsif args
+ configure('invalid', [cmd, args])
+ else
+ configure('invalid', cmd)
+ end
+ end
+=end
+
+ ####################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(index)
+ number(tk_send_without_enc('index', index))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb
new file mode 100644
index 0000000..e744fba
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb
@@ -0,0 +1,40 @@
+#
+# tkextlib/iwidgets/extbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extbutton < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Extbutton
+ TkCommandNames = ['::iwidgets::extbutton'.freeze].freeze
+ WidgetClassName = 'Extbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'bitmapforeground' << 'ringbackground'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'defaultring'
+ end
+ private :__boolval_optkeys
+
+ def invoke
+ tk_call(@path, 'invoke')
+ self
+ end
+
+ def flash
+ tk_call(@path, 'flash')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
new file mode 100644
index 0000000..2ff15bb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
@@ -0,0 +1,46 @@
+#
+# tkextlib/iwidgets/extfileselectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extfileselectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Extfileselectionbox
+ TkCommandNames = ['::iwidgets::extfileselectionbox'.freeze].freeze
+ WidgetClassName = 'Extfileselectionbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'dirslabel', 'fileslabel', 'filterlabel', 'mask', 'nomatchstring',
+ 'selectionlabel'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() + ['dirson', 'fileson', 'filteron', 'selectionon']
+ end
+ private :__boolval_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
new file mode 100644
index 0000000..509fdcf
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/extfileselectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extfileselectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Extfileselectiondialog
+ TkCommandNames = ['::iwidgets::extfileselectiondialog'.freeze].freeze
+ WidgetClassName = 'Extfileselectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb
new file mode 100644
index 0000000..29d04c8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb
@@ -0,0 +1,35 @@
+#
+# tkextlib/iwidgets/feedback.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Feedback < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Feedback
+ TkCommandNames = ['::iwidgets::feedback'.freeze].freeze
+ WidgetClassName = 'Feedback'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'barcolor'
+ end
+ private :__strval_optkeys
+
+ def reset
+ tk_call(@path, 'reset')
+ self
+ end
+
+ def step(inc=1)
+ tk_call(@path, 'step', inc)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
new file mode 100644
index 0000000..a425b53
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
@@ -0,0 +1,46 @@
+#
+# tkextlib/iwidgets/fileselectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Fileselectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Fileselectionbox
+ TkCommandNames = ['::iwidgets::fileselectionbox'.freeze].freeze
+ WidgetClassName = 'Fileselectionbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'directory', 'dirslabel', 'fileslabel', 'filterlabel', 'mask',
+ 'nomatchstring', 'selectionlabel'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() + ['dirson', 'fileson', 'filteron', 'selectionon']
+ end
+ private :__boolval_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
new file mode 100644
index 0000000..ebcdaf8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/fileselectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Fileselectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Fileselectiondialog
+ TkCommandNames = ['::iwidgets::fileselectiondialog'.freeze].freeze
+ WidgetClassName = 'Fileselectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb
new file mode 100644
index 0000000..3d522e0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb
@@ -0,0 +1,42 @@
+#
+# tkextlib/iwidgets/finddialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Finddialog < Tk::Iwidgets::Dialogshell
+ end
+ end
+end
+
+class Tk::Iwidgets::Finddialog
+ TkCommandNames = ['::iwidgets::finddialog'.freeze].freeze
+ WidgetClassName = 'Finddialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'patternbackground', 'patternforeground',
+ 'searchbackground', 'searchforeground'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ super().update('textwidget'=>proc{|v| window(v)})
+ end
+ private :__val2ruby_optkeys
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def find
+ tk_call(@path, 'find')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
new file mode 100644
index 0000000..cb9301d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
@@ -0,0 +1,365 @@
+#
+# tkextlib/iwidgets/hierarchy.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Hierarchy < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Hierarchy
+ ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
+ include TkTextTagConfig
+
+ TkCommandNames = ['::iwidgets::hierarchy'.freeze].freeze
+ WidgetClassName = 'Hierarchy'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class QueryCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [ [?n, ?s, :node], nil ]
+ PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['querycommand']
+ end
+ end
+
+ class IndicatorCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?n, ?s, :node ],
+ [ ?s, ?b, :status ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?b, TkComm.method(:bool) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['iconcommand', 'icondblcommand', 'imagedblcommand']
+ end
+ end
+
+ class IconCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?n, ?s, :node ],
+ [ ?i, ?s, :icon ],
+ nil
+ ]
+ PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['dblclickcommand', 'imagecommand', 'selectcommand']
+ end
+ end
+
+ def __validation_class_list
+ super() << QueryCommand << IndicatorCommand << IconCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, QueryCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, IndicatorCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, IconCommand)
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'alwaysquery' << 'expanded' << 'filter'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'markbackground' << 'markforeground' << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def collapse(node)
+ tk_call(@path, 'collapse')
+ self
+ end
+
+ def current
+ tk_call(@path, 'current')
+ end
+
+ def draw(mode=None)
+ case mode
+ when None
+ # do nothing
+ when 'now', :now
+ mode = '-now'
+ when 'eventually', :eventually
+ mode = '-eventually'
+ when String, Symbol
+ mode = mode.to_s
+ mode = '-' << mode if mode[0] != ?-
+ end
+ tk_call(@path, 'draw', mode)
+ end
+
+ def expand(node)
+ tk_call(@path, 'expand', node)
+ self
+ end
+
+ def expanded?(node)
+ bool(tk_call(@path, 'expanded', node))
+ end
+
+ def exp_state
+ list(tk_call(@path, 'expState'))
+ end
+ alias expand_state exp_state
+ alias expanded_list exp_state
+
+ def mark_clear
+ tk_call(@path, 'mark', 'clear')
+ self
+ end
+ def mark_add(*nodes)
+ tk_call(@path, 'mark', 'add', *nodes)
+ self
+ end
+ def mark_remove(*nodes)
+ tk_call(@path, 'mark', 'remove', *nodes)
+ self
+ end
+ def mark_get
+ list(tk_call(@path, 'mark', 'get'))
+ end
+
+ def refresh(node)
+ tk_call(@path, 'refresh', node)
+ self
+ end
+
+ def prune(node)
+ tk_call(@path, 'prune', node)
+ self
+ end
+
+ def selection_clear
+ tk_call(@path, 'selection', 'clear')
+ self
+ end
+ def selection_add(*nodes)
+ tk_call(@path, 'selection', 'add', *nodes)
+ self
+ end
+ def selection_remove(*nodes)
+ tk_call(@path, 'selection', 'remove', *nodes)
+ self
+ end
+ def selection_get
+ list(tk_call(@path, 'selection', 'get'))
+ end
+
+ def toggle(node)
+ tk_call(@path, 'toggle', node)
+ self
+ end
+
+ # based on Tk::Text widget
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
+ end
+
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+
+ def index(index)
+ tk_send_without_enc('index', _get_eval_enc_str(index))
+ end
+
+ def insert(index, chars, *tags)
+ if tags[0].kind_of? Array
+ # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
+ args = [chars]
+ while tags.size > 0
+ args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
+ args << tags.shift if tags.size > 0 # chars
+ end
+ super(index, *args)
+ else
+ # single chars-taglist argument :: str, tag, tag, ...
+ if tags.size == 0
+ super(index, chars)
+ else
+ super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' '))
+ end
+ end
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
new file mode 100644
index 0000000..d4ea1aa
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
@@ -0,0 +1,50 @@
+#
+# tkextlib/iwidgets/hyperhelp.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Hyperhelp < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Hyperhelp
+ TkCommandNames = ['::iwidgets::hyperhelp'.freeze].freeze
+ WidgetClassName = 'Hyperhelp'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helpdir'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'topics'
+ end
+ private :__listval_optkeys
+
+ def show_topic(topic)
+ tk_call(@path, 'showtopic', topic)
+ self
+ end
+
+ def follow_link(href)
+ tk_call(@path, 'followlink', href)
+ self
+ end
+
+ def forward
+ tk_call(@path, 'forward')
+ self
+ end
+
+ def back
+ tk_call(@path, 'back')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
new file mode 100644
index 0000000..6595398
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
@@ -0,0 +1,39 @@
+#
+# tkextlib/iwidgets/labeledframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Labeledframe < Tk::Itk::Archetype
+ end
+ end
+end
+
+class Tk::Iwidgets::Labeledframe
+ TkCommandNames = ['::iwidgets::labeledframe'.freeze].freeze
+ WidgetClassName = 'Labeledframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'labeltext'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'labelvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'labelfont'
+ end
+ private :__font_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
new file mode 100644
index 0000000..d36d428
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/iwidgets/labeledwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Labeledwidget < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Labeledwidget
+ extend TkCore
+
+ TkCommandNames = ['::iwidgets::labeledwidget'.freeze].freeze
+ WidgetClassName = 'Labeledwidget'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'labeltext'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'labelvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'labelfont'
+ end
+ private :__font_optkeys
+
+ def self.alignlabels(*wins)
+ tk_call('::iwidgets::Labeledwidget::alignlabels', *wins)
+ end
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
new file mode 100644
index 0000000..ebf4802
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
@@ -0,0 +1,67 @@
+#
+# tkextlib/iwidgets/mainwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Mainwindow < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Mainwindow
+ TkCommandNames = ['::iwidgets::mainwindow'.freeze].freeze
+ WidgetClassName = 'Mainwindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'helpline' << 'statusline'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'menubarbackground' << 'menubarforeground' << 'toolbarforeground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'menubarfont' << 'toolbarfont'
+ end
+ private :__font_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def menubar(*args)
+ unless args.empty?
+ tk_call(@path, 'menubar', *args)
+ end
+ window(tk_call(@path, 'menubar'))
+ end
+
+ def mousebar(*args)
+ unless args.empty?
+ tk_call(@path, 'mousebar', *args)
+ end
+ window(tk_call(@path, 'mousebar'))
+ end
+
+ def msgd(*args)
+ unless args.empty?
+ tk_call(@path, 'msgd', *args)
+ end
+ window(tk_call(@path, 'msgd'))
+ end
+
+ def toolbar(*args)
+ unless args.empty?
+ tk_call(@path, 'toolbar', *args)
+ end
+ window(tk_call(@path, 'toolbar'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb
new file mode 100644
index 0000000..f9a17d0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb
@@ -0,0 +1,212 @@
+#
+# tkextlib/iwidgets/menubar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Menubar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Menubar
+ TkCommandNames = ['::iwidgets::menubar'.freeze].freeze
+ WidgetClassName = 'Menubar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'menubuttons'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvariable'
+ end
+ private :__tkvariable_optkeys
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'menucget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'menuconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'selectcolor'
+ end
+ private :__item_strval_optkeys
+
+ def __item_tkvariable_optkeys(id)
+ super(id) << 'helpstr'
+ end
+ private :__item_tkvariable_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias menucget_tkstring itemcget_tkstring
+ alias menucget itemcget
+ alias menucget_strict itemcget_strict
+ alias menuconfigure itemconfigure
+ alias menuconfiginfo itemconfiginfo
+ alias current_menuconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __methodcall_optkeys
+ {'menubuttons'=>'menubuttons'}
+ end
+
+ def menubuttons(val = nil)
+ unless val
+ return tk_call(@path, 'cget', '-menubuttons')
+ end
+
+ tk_call(@path, 'configure', '-menubuttons', _parse_menu_spec(val))
+ self
+ end
+
+ def _parse_menu_spec(menu_spec)
+ ret = ''
+ menu_spec.each{|spec|
+ next unless spec
+
+ if spec.kind_of?(Hash)
+ args = [spec]
+ type = 'options'
+ else
+ type, *args = spec
+ end
+
+ type = type.to_s
+ case type
+ when 'options'
+ keys = args[0]
+ ary = [type]
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+
+ when 'menubutton', 'cascade'
+ name, keys = args
+ if keys
+ ary = [type, name]
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+ else
+ ret << array2tk_list([type, name]) << "\n"
+ end
+
+ else
+ name, keys = args
+ if keys
+ ary = [type, name]
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+ else
+ ret << array2tk_list([type, name]) << "\n"
+ end
+ end
+ }
+ ret
+ end
+
+ ####################################
+
+ def add(type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(path1, path2=nil)
+ if path2
+ else
+ tk_call(@path, 'delete', index(idx))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx)
+ tk_call(@path, 'invoke', index(idx))
+ self
+ end
+
+ def menupath(pat)
+ if (win = tk_call(@path, 'path', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+ def menupath_glob(pat)
+ if (win = tk_call(@path, 'path', '-glob', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+ def menupath_tclregexp(pat)
+ if (win = tk_call(@path, 'path', '-regexp', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+
+ def type(path)
+ tk_call(@path, 'type', path)
+ end
+
+ def yposition(path)
+ number(tk_call(@path, 'yposition', path))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
new file mode 100644
index 0000000..6adb53d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
@@ -0,0 +1,93 @@
+#
+# tkextlib/iwidgets/messagebox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Messagebox < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Messagebox
+ TkCommandNames = ['::iwidgets::messagebox'.freeze].freeze
+ WidgetClassName = 'Messagebox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'type', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'type', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'bell' << 'show'
+ end
+ private :__item_boolval_optkeys
+
+ alias typecget_tkstring itemcget_tkstring
+ alias typecget itemcget
+ alias typecget_strict itemcget_strict
+ alias typeconfigure itemconfigure
+ alias typeconfiginfo itemconfiginfo
+ alias current_typeconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __strval_optkeys
+ super() << 'filename' << 'savedir'
+ end
+ private :__strval_optkeys
+
+ def type_add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ unless tag
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'type', 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def export(file)
+ tk_call(@path, 'export', file)
+ self
+ end
+
+ def issue(string, type=None, *args)
+ tk_call(@path, 'issue', string, tagid(type), *args)
+ self
+ end
+
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
new file mode 100644
index 0000000..9aa5900
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/messagedialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Messagedialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Messagedialog
+ TkCommandNames = ['::iwidgets::messagedialog'.freeze].freeze
+ WidgetClassName = 'Messagedialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb
new file mode 100644
index 0000000..7ed4126
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/iwidgets/notebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Notebook < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Notebook
+ TkCommandNames = ['::iwidgets::notebook'.freeze].freeze
+ WidgetClassName = 'Notebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'pagecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'pageconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias pagecget_tkstring itemcget_tkstring
+ alias pagecget itemcget
+ alias pagecget_strict itemcget_strict
+ alias pageconfigure itemconfigure
+ alias pageconfiginfo itemconfiginfo
+ alias current_pageconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'auto'
+ end
+ private :__boolval_optkeys
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ window(tk_call(@path, 'childsite', new_idx))
+ end
+
+ def delete(idx1, idx2=nil)
+ if (new_idx1 = self.index(idx1)) < 0
+ new_idx1 = tagid(idx1)
+ end
+ if idx2
+ if (new_idx2 = self.index(idx2)) < 0
+ new_idx2 = tagid(idx2)
+ end
+ tk_call(@path, 'delete', new_idx1, new_idx2)
+ else
+ tk_call(@path, 'delete', new_idx1)
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, keys={})
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ window(tk_call(@path, 'insert', new_idx, *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ tk_call(@path, 'select', new_idx)
+ self
+ end
+
+ def scrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias xscrollcommand scrollcommand
+ alias yscrollcommand scrollcommand
+
+ def xscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'horizontal'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ def yscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'vertical'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ alias scrollbar yscrollbar
+
+ def view(*idxs)
+ if idxs.size == 0
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
+ else
+ tk_send_without_enc('view', *idxs)
+ self
+ end
+ end
+ alias xview view
+ alias yview view
+
+ def view_moveto(*idxs)
+ view('moveto', *idxs)
+ end
+ alias xview_moveto view_moveto
+ alias yview_moveto view_moveto
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
+ end
+ alias xview_scroll view_scroll
+ alias yview_scroll view_scroll
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
new file mode 100644
index 0000000..57a3cc7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
@@ -0,0 +1,92 @@
+#
+# tkextlib/iwidgets/optionmenu.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Optionmenu < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Optionmenu
+ TkCommandNames = ['::iwidgets::optionmenu'.freeze].freeze
+ WidgetClassName = 'Optionmenu'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'cyclicon'
+ end
+ private :__boolval_optkeys
+
+ def delete(first, last=nil)
+ if last
+ tk_call(@path, 'delete', first, last)
+ else
+ tk_call(@path, 'delete', first)
+ end
+ self
+ end
+
+ def disable(idx)
+ tk_call(@path, 'disable', idx)
+ self
+ end
+
+ def enable(idx)
+ tk_call(@path, 'enable', idx)
+ self
+ end
+
+ def get(first=nil, last=nil)
+ if last
+ simplelist(tk_call(@path, 'get', first, last))
+ elsif first
+ tk_call(@path, 'get', first)
+ else
+ tk_call(@path, 'get')
+ end
+ end
+ def get_range(first, last)
+ get(first, last)
+ end
+ def get_selected
+ get()
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', idx))
+ end
+
+ def insert(idx, *args)
+ tk_call(@path, 'insert', idx, *args)
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', idx)
+ self
+ end
+
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
new file mode 100644
index 0000000..65463cc
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
@@ -0,0 +1,134 @@
+#
+# tkextlib/iwidgets/panedwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Panedwindow < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Panedwindow
+ TkCommandNames = ['::iwidgets::panedwindow'.freeze].freeze
+ WidgetClassName = 'Panedwindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'panecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'paneconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias panecget_tkstring itemcget_tkstring
+ alias panecget itemcget
+ alias panecget_strict itemcget_strict
+ alias paneconfigure itemconfigure
+ alias paneconfiginfo itemconfiginfo
+ alias current_paneconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'showhandle'
+ end
+ private :__boolval_optkeys
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'add', tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ window(tk_call(@path, 'childsite', index(idx)))
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def fraction(*percentages)
+ tk_call(@path, 'fraction', *percentages)
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def reset
+ tk_call(@path, 'reset')
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
new file mode 100644
index 0000000..7c7ff7a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
@@ -0,0 +1,131 @@
+#
+# tkextlib/iwidgets/promptdialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Promptdialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Promptdialog
+ TkCommandNames = ['::iwidgets::promptdialog'.freeze].freeze
+ WidgetClassName = 'Promptdialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ # index method is not available, because it shows index of the entry field
+ def default(name)
+ tk_call(@path, 'default', tagid(name))
+ self
+ end
+
+ def hide(name)
+ tk_call(@path, 'hide', tagid(name))
+ self
+ end
+
+ def invoke(name=nil)
+ if name
+ tk_call(@path, 'invoke', tagid(name))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(name)
+ tk_call(@path, 'show', tagid(name))
+ self
+ end
+
+
+ # based on Tk::Iwidgets::Entryfield
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(idx)
+ number(tk_send_without_enc('index', idx))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
new file mode 100644
index 0000000..ae56788
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
@@ -0,0 +1,35 @@
+#
+# tkextlib/iwidgets/pushbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Pushbutton < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Pushbutton
+ TkCommandNames = ['::iwidgets::pushbutton'.freeze].freeze
+ WidgetClassName = 'Pushbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'defaultring'
+ end
+ private :__boolval_optkeys
+
+ def invoke
+ tk_call_without_enc(@path, 'invoke')
+ self
+ end
+
+ def flash
+ tk_call_without_enc(@path, 'flash')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
new file mode 100644
index 0000000..2118177
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -0,0 +1,121 @@
+#
+# tkextlib/iwidgets/radiobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Radiobox < Tk::Iwidgets::Labeledframe
+ end
+ end
+end
+
+class Tk::Iwidgets::Radiobox
+ TkCommandNames = ['::iwidgets::radiobox'.freeze].freeze
+ WidgetClassName = 'Radiobox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def deselect(idx)
+ tk_call(@path, 'deselect', index(idx))
+ self
+ end
+
+ def flash(idx)
+ tk_call(@path, 'flash', index(idx))
+ self
+ end
+
+ def get_tag
+ ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag
+ end
+ alias get get_tag
+
+ def get_obj
+ (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
new file mode 100644
index 0000000..056cd85
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
@@ -0,0 +1,24 @@
+#
+# tkextlib/iwidgets/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scopedobject < TkObject
+ end
+ end
+end
+
+class Tk::Iwidgets::Scopedobject
+ TkCommandNames = ['::iwidgets::scopedobject'.freeze].freeze
+ WidgetClassName = 'Scopedobject'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def initialize(obj_name, keys={})
+ @path = tk_call(self.class::TkCommandNames[0], obj_name, *hash_kv(keys))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
new file mode 100644
index 0000000..4dea2f2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -0,0 +1,353 @@
+#
+# tkextlib/iwidgets/scrolledcanvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledcanvas < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledcanvas
+ TkCommandNames = ['::iwidgets::scrolledcanvas'.freeze].freeze
+ WidgetClassName = 'Scrolledcanvas'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ################################
+
+ def __boolval_optkeys
+ super() << 'autoresize'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def initialize(*args)
+ super(*args)
+ @canvas = component_widget('canvas')
+ end
+
+ def method_missing(id, *args)
+ if @canvas.respond_to?(id)
+ @canvas.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ ##########################
+ include TkCanvasItemConfig
+
+ def tagid(tag)
+ if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
+ tag.id
+ elsif tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+ private :tagid
+
+ # create a canvas item without creating a TkcItem object
+ def create(type, *args)
+ type.create(self, *args)
+ end
+
+ #######################
+
+ def addtag(tag, mode, *args)
+ tk_send_without_enc('addtag', tagid(tag), mode, *args)
+ self
+ end
+ def addtag_above(tagOrId, target)
+ addtag(tagOrId, 'above', tagid(target))
+ end
+ def addtag_all(tagOrId)
+ addtag(tagOrId, 'all')
+ end
+ def addtag_below(tagOrId, target)
+ addtag(tagOrId, 'below', tagid(target))
+ end
+ def addtag_closest(tagOrId, x, y, halo=None, start=None)
+ addtag(tagOrId, 'closest', x, y, halo, start)
+ end
+ def addtag_enclosed(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
+ end
+ def addtag_overlapping(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
+ end
+ def addtag_withtag(tagOrId, tag)
+ addtag(tagOrId, 'withtag', tagid(tag))
+ end
+
+ def bbox(tagOrId, *tags)
+ list(tk_send_without_enc('bbox', tagid(tagOrId),
+ *tags.collect{|t| tagid(t)}))
+ end
+
+ #def itembind(tag, context, cmd=Proc.new, *args)
+ # _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def itembind(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+
+ #def itembind_append(tag, context, cmd=Proc.new, *args)
+ # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def itembind_append(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+
+ def itembind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+
+ def itembindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def canvasx(screen_x, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
+ number(tk_send_without_enc('canvasx', screen_x, *args))
+ end
+ def canvasy(screen_y, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
+ number(tk_send_without_enc('canvasy', screen_y, *args))
+ end
+
+ def coords(tag, *args)
+ if args == []
+ tk_split_list(tk_send_without_enc('coords', tagid(tag)))
+ else
+ tk_send_without_enc('coords', tagid(tag), *(args.flatten))
+ self
+ end
+ end
+
+ def dchars(tag, first, last=None)
+ tk_send_without_enc('dchars', tagid(tag),
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
+ self
+ end
+
+ def delete(*args)
+ tbl = nil
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl = TkcItem::CItemID_TBL[self.path]
+ }
+ if tbl
+ find('withtag', *args).each{|item|
+ if item.kind_of?(TkcItem)
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl.delete(item.id)
+ }
+ end
+ }
+ end
+ tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
+ self
+ end
+ alias remove delete
+
+ def dtag(tag, tag_to_del=None)
+ tk_send_without_enc('dtag', tagid(tag), tag_to_del)
+ self
+ end
+
+ def find(mode, *args)
+ list(tk_send_without_enc('find', mode, *args)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+ def find_above(target)
+ find('above', tagid(target))
+ end
+ def find_all
+ find('all')
+ end
+ def find_below(target)
+ find('below', tagid(target))
+ end
+ def find_closest(x, y, halo=None, start=None)
+ find('closest', x, y, halo, start)
+ end
+ def find_enclosed(x1, y1, x2, y2)
+ find('enclosed', x1, y1, x2, y2)
+ end
+ def find_overlapping(x1, y1, x2, y2)
+ find('overlapping', x1, y1, x2, y2)
+ end
+ def find_withtag(tag)
+ find('withtag', tag)
+ end
+
+ def itemfocus(tagOrId=nil)
+ if tagOrId
+ tk_send_without_enc('focus', tagid(tagOrId))
+ self
+ else
+ ret = tk_send_without_enc('focus')
+ if ret == ""
+ nil
+ else
+ TkcItem.id2obj(self, ret)
+ end
+ end
+ end
+
+ def gettags(tagOrId)
+ list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
+ TkcTag.id2obj(self, tag)
+ }
+ end
+
+ def icursor(tagOrId, index)
+ tk_send_without_enc('icursor', tagid(tagOrId), index)
+ self
+ end
+
+ def index(tagOrId, idx)
+ number(tk_send_without_enc('index', tagid(tagOrId), idx))
+ end
+
+ def insert(tagOrId, index, string)
+ tk_send_without_enc('insert', tagid(tagOrId), index,
+ _get_eval_enc_str(string))
+ self
+ end
+
+ def lower(tag, below=nil)
+ if below
+ tk_send_without_enc('lower', tagid(tag), tagid(below))
+ else
+ tk_send_without_enc('lower', tagid(tag))
+ end
+ self
+ end
+
+ def move(tag, x, y)
+ tk_send_without_enc('move', tagid(tag), x, y)
+ self
+ end
+
+ def postscript(keys)
+ tk_send("postscript", *hash_kv(keys))
+ end
+
+ def raise(tag, above=nil)
+ if above
+ tk_send_without_enc('raise', tagid(tag), tagid(above))
+ else
+ tk_send_without_enc('raise', tagid(tag))
+ end
+ self
+ end
+
+ def scale(tag, x, y, xs, ys)
+ tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def select(mode, *args)
+ r = tk_send_without_enc('select', mode, *args)
+ (mode == 'item')? TkcItem.id2obj(self, r): self
+ end
+ def select_adjust(tagOrId, index)
+ select('adjust', tagid(tagOrId), index)
+ end
+ def select_clear
+ select('clear')
+ end
+ def select_from(tagOrId, index)
+ select('from', tagid(tagOrId), index)
+ end
+ def select_item
+ select('item')
+ end
+ def select_to(tagOrId, index)
+ select('to', tagid(tagOrId), index)
+ end
+
+ def itemtype(tag)
+ TkcItem.type2class(tk_send('type', tagid(tag)))
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
new file mode 100644
index 0000000..7b7b95d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
@@ -0,0 +1,59 @@
+#
+# tkextlib/iwidgets/scrolledframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledframe < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledframe
+ TkCommandNames = ['::iwidgets::scrolledframe'.freeze].freeze
+ WidgetClassName = 'Scrolledframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
new file mode 100644
index 0000000..dc2966b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/iwidgets/scrolledhtml.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledhtml < Tk::Iwidgets::Scrolledtext
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledhtml
+ TkCommandNames = ['::iwidgets::scrolledhtml'.freeze].freeze
+ WidgetClassName = 'Scrolledhtml'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'update'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'fontname' << 'link' << 'alink' << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'fixedfont'
+ end
+ private :__font_optkeys
+
+ def import(href)
+ tk_call(@path, 'import', href)
+ self
+ end
+
+ def import_link(href)
+ tk_call(@path, 'import', '-link', href)
+ self
+ end
+
+ def pwd
+ tk_call(@path, 'pwd')
+ end
+
+ def render(htmltext, workdir=None)
+ tk_call(@path, 'render', htmltext, workdir)
+ self
+ end
+
+ def title
+ tk_call(@path, 'title')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
new file mode 100644
index 0000000..20a4cd1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
@@ -0,0 +1,207 @@
+#
+# tkextlib/iwidgets/scrolledlistbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/listbox'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledlistbox < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledlistbox
+ TkCommandNames = ['::iwidgets::scrolledlistbox'.freeze].freeze
+ WidgetClassName = 'Scrolledlistbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'listvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @listbox = component_widget('listbox')
+ end
+
+ def method_missing(id, *args)
+ if @listbox.respond_to?(id)
+ @listbox.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def get_curselection
+ tk_call(@path, 'getcurselection')
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ def selected_item_count
+ number(tk_call(@path, 'selecteditemcount'))
+ end
+
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+
+ #####################################
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ #####################################
+
+ include TkListItemConfig
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ super(tag)
+ end
+ end
+ private :tagid
+
+ #####################################
+
+ def activate(y)
+ tk_send_without_enc('activate', y)
+ self
+ end
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def get(first, last=nil)
+ if last
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
+ tk_split_simplelist(tk_send_without_enc('get', first, last),
+ false, true)
+ else
+ _fromUTF8(tk_send_without_enc('get', first))
+ end
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+
+ #####################################
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
new file mode 100644
index 0000000..69b7d31
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -0,0 +1,568 @@
+#
+# tkextlib/iwidgets/scrolledtext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledtext < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledtext
+ TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze
+ WidgetClassName = 'Scrolledtext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @text = component_widget('text')
+ end
+
+ def method_missing(id, *args)
+ if @text.respond_to?(id)
+ @text.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def import(file, idx=nil)
+ if idx
+ tk_call(@path, 'import', file, index(idx))
+ else
+ tk_call(@path, 'import', file)
+ end
+ self
+ end
+
+ def export(file)
+ tk_call(@path, 'export', file)
+ self
+ end
+
+ #####################################
+
+ include TkTextTagConfig
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ super(tag)
+ end
+ end
+ private :tagid
+
+ def bbox(index)
+ list(tk_send('bbox', index))
+ end
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def get_displaychars(*index)
+ # Tk8.5 feature
+ get('-displaychars', *index)
+ end
+
+ def image_cget_tkstring(index, slot)
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot.to_s}"))
+ end
+ def image_cget_strict(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index),
+ "-#{slot}")))
+ end
+ end
+ def image_cget(index, slot)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ image_cget_strict(index, slot)
+ else
+ begin
+ image_cget_strict(index, slot)
+ rescue => e
+ begin
+ if current_image_configinfo.has_key?(slot.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+
+ def image_configure(index, slot, value=None)
+ if slot.kind_of? Hash
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true)))
+ else
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}",
+ _get_eval_enc_str(value)))
+ end
+ self
+ end
+
+ def image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
+ else
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).collect{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
+ else
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).each{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = image_configinfo(index, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ image_configinfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ image_configinfo(index, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ def image_names
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('image', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def index(idx)
+ tk_send_without_enc('index', _get_eval_enc_str(idx))
+ end
+
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+
+ def mark_names
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('mark', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_gravity(mark, direction=nil)
+ if direction
+ tk_send_without_enc('mark', 'gravity',
+ _get_eval_enc_str(mark), direction)
+ self
+ else
+ tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
+ end
+ end
+
+ def mark_set(mark, index)
+ tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
+ _get_eval_enc_str(index))
+ self
+ end
+ alias set_mark mark_set
+
+ def mark_unset(*marks)
+ tk_send_without_enc('mark', 'unset',
+ *(marks.collect{|mark| _get_eval_enc_str(mark)}))
+ self
+ end
+ alias unset_mark mark_unset
+
+ def mark_next(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
+ _get_eval_enc_str(index))))
+ end
+ alias next_mark mark_next
+
+ def mark_previous(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
+ _get_eval_enc_str(index))))
+ end
+ alias previous_mark mark_previous
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+
+ def _ktext_length(txt)
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
+ return txt.length
+ end
+ ###########################
+
+ if $KCODE !~ /n/i
+ return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
+ end
+
+ # $KCODE == 'NONE'
+ if JAPANIZED_TK
+ tk_call_without_enc('kstring', 'length',
+ _get_eval_enc_str(txt)).to_i
+ else
+ begin
+ tk_call_without_enc('encoding', 'convertto', 'ascii',
+ _get_eval_enc_str(txt)).length
+ rescue StandardError, NameError
+ # sorry, I have no plan
+ txt.length
+ end
+ end
+ end
+ private :_ktext_length
+
+ def tksearch(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
+ else
+ opts = []
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def tksearch_with_count(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
+ else
+ opts = []
+ end
+
+ opts << '-count' << args.shift << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def search_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'>=',stop)
+ txt = get(start,stop)
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get(start,'end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def search(pat,start,stop=None)
+ search_with_length(pat,start,stop)[0]
+ end
+
+ def rsearch_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'<=',stop)
+ txt = get(stop,start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(stop + " + #{pos} chars"), pat.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index(stop + " + #{pos} chars"), $&.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get('1.0',start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def rsearch(pat,start,stop=None)
+ rsearch_with_length(pat,start,stop)[0]
+ end
+
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ ###############################
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
new file mode 100644
index 0000000..5ecd2d7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/scrolledwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledwidget < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledwidget
+ TkCommandNames = ['::iwidgets::scrolledwidget'.freeze].freeze
+ WidgetClassName = 'Scrolledwidget'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
new file mode 100644
index 0000000..eb8fe3a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
@@ -0,0 +1,102 @@
+#
+# tkextlib/iwidgets/selectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Selectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Selectionbox
+ TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze
+ WidgetClassName = 'Selectionbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'itemson' << 'selectionon'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'itemslabel' << 'selectionlabel'
+ end
+ private :__strval_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear_items
+ tk_call(@path, 'clear', 'items')
+ self
+ end
+
+ def clear_selection
+ tk_call(@path, 'clear', 'selection')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+
+ def insert_items(idx, *args)
+ tk_call(@path, 'insert', 'items', idx, *args)
+ end
+
+ def insert_selection(pos, text)
+ tk_call(@path, 'insert', 'selection', pos, text)
+ end
+
+ def select_item
+ tk_call(@path, 'selectitem')
+ self
+ end
+
+ # based on Tk::Listbox ( and TkTextWin )
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
new file mode 100644
index 0000000..45aecf3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
@@ -0,0 +1,92 @@
+#
+# tkextlib/iwidgets/selectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Selectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Selectiondialog
+ TkCommandNames = ['::iwidgets::selectiondialog'.freeze].freeze
+ WidgetClassName = 'Selectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear_items
+ tk_call(@path, 'clear', 'items')
+ self
+ end
+
+ def clear_selection
+ tk_call(@path, 'clear', 'selection')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+
+ def insert_items(idx, *args)
+ tk_call(@path, 'insert', 'items', idx, *args)
+ end
+
+ def insert_selection(pos, text)
+ tk_call(@path, 'insert', 'selection', pos, text)
+ end
+
+ def select_item
+ tk_call(@path, 'selectitem')
+ self
+ end
+
+ # based on Tk::Listbox ( and TkTextWin )
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb
new file mode 100644
index 0000000..c560e3a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/shell.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Shell < Tk::Itk::Toplevel
+ end
+ end
+end
+
+class Tk::Iwidgets::Shell
+ TkCommandNames = ['::iwidgets::shell'.freeze].freeze
+ WidgetClassName = 'Shell'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def activate
+ tk_call(@path, 'activate') # may return val of deactibate method
+ end
+
+ def center(win=None)
+ tk_call(@path, 'center', win)
+ self
+ end
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def deactivate(val=None)
+ tk_call(@path, 'deactivate', val)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb
new file mode 100644
index 0000000..b3de9ed
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb
@@ -0,0 +1,48 @@
+#
+# tkextlib/iwidgets/spindate.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spindate < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spindate
+ TkCommandNames = ['::iwidgets::spindate'.freeze].freeze
+ WidgetClassName = 'Spindate'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'dayon' << 'monthon' << 'yearon'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'daylabel' << 'monthformat' << 'monthlabel' << 'yearlabel'
+ end
+ private :__strval_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb
new file mode 100644
index 0000000..bede3bb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/iwidgets/spinint.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spinint < Tk::Iwidgets::Spinner
+ end
+ end
+end
+
+class Tk::Iwidgets::Spinint
+ TkCommandNames = ['::iwidgets::spinint'.freeze].freeze
+ WidgetClassName = 'Spinint'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ super() << 'range'
+ end
+ private :__numlistval_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb
new file mode 100644
index 0000000..d960996
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb
@@ -0,0 +1,169 @@
+#
+# tkextlib/iwidgets/spinner.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spinner < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spinner
+ TkCommandNames = ['::iwidgets::spinner'.freeze].freeze
+ WidgetClassName = 'Spinner'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class EntryfieldValidate < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?s, :char ],
+ [ ?P, ?s, :post ],
+ [ ?S, ?s, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['validate', 'invalid']
+ end
+ end
+
+ def __validation_class_list
+ super() << EntryfieldValidate
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
+
+ ####################################
+
+ def up
+ tk_call_without_enc(@path, 'up')
+ self
+ end
+
+ def down
+ tk_call_without_enc(@path, 'down')
+ self
+ end
+
+ def clear
+ tk_call_without_enc(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(idx)
+ number(tk_send_without_enc('index', idx))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb
new file mode 100644
index 0000000..20f8197
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb
@@ -0,0 +1,48 @@
+#
+# tkextlib/iwidgets/spintime.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spintime < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spintime
+ TkCommandNames = ['::iwidgets::spintime'.freeze].freeze
+ WidgetClassName = 'Spintime'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'houron' << 'militaryon' << 'minutelabel' << 'secondlabel'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'hourlabel' << 'minuteon' << 'secondon'
+ end
+ private :__strval_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
new file mode 100644
index 0000000..f56efa9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
@@ -0,0 +1,181 @@
+#
+# tkextlib/iwidgets/tabnotebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Tabnotebook < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Tabnotebook
+ TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze
+ WidgetClassName = 'Tabnotebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'pagecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'pageconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'tabbackground' << 'tabforeground'
+ end
+ private :__item_strval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias pagecget_tkstring itemcget_tkstring
+ alias pagecget itemcget
+ alias pagecget_strict itemcget_strict
+ alias pageconfigure itemconfigure
+ alias pageconfiginfo itemconfiginfo
+ alias current_pageconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'auto' << 'equaltabs' << 'raiseselect' << 'tabborders'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'backdrop' << 'tabbackground' << 'tabforeground'
+ end
+ private :__strval_optkeys
+
+ def initialize(*args)
+ super(*args)
+ @tabset = self.component_widget('tabset')
+ end
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ window(tk_call(@path, 'childsite', index(idx)))
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ #number(tk_call(@path, 'index', tagid(idx)))
+ @tabset.index(tagid(idx))
+ end
+
+ def insert(idx, keys={})
+ window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+
+ def show_tab(idx)
+ @tabset.show_tab(idx)
+ self
+ end
+
+ def scrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias xscrollcommand scrollcommand
+ alias yscrollcommand scrollcommand
+
+ def xscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'horizontal'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ def yscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'vertical'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ alias scrollbar yscrollbar
+
+ def view(*index)
+ if index.size == 0
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
+ else
+ tk_send_without_enc('view', *index)
+ self
+ end
+ end
+ alias xview view
+ alias yview view
+
+ def view_moveto(*index)
+ view('moveto', *index)
+ end
+ alias xview_moveto view_moveto
+ alias yview_moveto view_moveto
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
+ end
+ alias xview_scroll view_scroll
+ alias yview_scroll view_scroll
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb
new file mode 100644
index 0000000..501ead4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb
@@ -0,0 +1,145 @@
+#
+# tkextlib/iwidgets/tabset.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Tabset < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Tabset
+ TkCommandNames = ['::iwidgets::tabset'.freeze].freeze
+ WidgetClassName = 'Tabset'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tabcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tabconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias tabcget_tkstring itemcget_tkstring
+ alias tabcget itemcget
+ alias tabcget_strict itemcget_strict
+ alias tabconfigure itemconfigure
+ alias tabconfiginfo itemconfiginfo
+ alias current_tabconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'equaltabs' << 'raiseselect' << 'tabborders'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'backdrop'
+ end
+ private :__strval_optkeys
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, keys={})
+ window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+
+ def show_tab(idx)
+ if index(idx) == 0
+ self.start = 0
+ return
+ end
+
+ reutrn unless @canvas ||= self.winfo_children[0]
+
+ delta = 1 if (delta = cget(:gap)) == 'overlap' ||
+ (delta = self.winfo_pixels(delta) + 1) <= 0
+
+ case cget(:tabpos)
+ when 's', 'n'
+ if (head = tabcget(idx, :left)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_width
+ tab_start, tab_end = @canvas .
+ find_overlapping(head, 0, head + delta, @canvas.winfo_height) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[0], bbox[2]]} . max
+
+ when 'e', 'w'
+ if (head = tabcget(idx, :top)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_height
+ tab_start, tab_end = @canvas .
+ find_overlapping(0, head, @canvas.winfo_width, head + delta) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[1], bbox[3]]} . max
+ end
+
+ if (size = tab_end - tab_start + 1) > tabs_size
+ self.start -= tab_start
+ elsif head + size > tabs_size
+ self.start -= head + size - tabs_size
+ end
+
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb
new file mode 100644
index 0000000..b0afb3a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb
@@ -0,0 +1,25 @@
+#
+# tkextlib/iwidgets/timeentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Timeentry < Tk::Iwidgets::Timefield
+ end
+ end
+end
+
+class Tk::Iwidgets::Timeentry
+ TkCommandNames = ['::iwidgets::timeentry'.freeze].freeze
+ WidgetClassName = 'Timeentry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'closetext'
+ end
+ private :__strval_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb
new file mode 100644
index 0000000..c34281d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/iwidgets/timefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Timefield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Timefield
+ TkCommandNames = ['::iwidgets::timefield'.freeze].freeze
+ WidgetClassName = 'Timefield'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'gmt'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def valid?
+ bool(tk_call(@path, 'isvalid'))
+ end
+ alias isvalid? valid?
+
+ def show(time=None)
+ tk_call(@path, 'show', time)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
new file mode 100644
index 0000000..5b474c3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
@@ -0,0 +1,112 @@
+#
+# tkextlib/iwidgets/toolbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Toolbar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Toolbar
+ TkCommandNames = ['::iwidgets::toolbar'.freeze].freeze
+ WidgetClassName = 'Toolbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __tkvariable_optkeys
+ super() << 'helpvariable'
+ end
+ private :__tkvariable_optkeys
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'itemcget', self.index(id)]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'itemconfigure', self.index(id)]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'helpstr' << 'balloonstr'
+ end
+ private :__item_strval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ ####################################
+
+ def __strval_optkeys
+ super() << 'balloonbackground' << 'balloonforeground'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'balloonfont'
+ end
+ private :__font_optkeys
+
+ def add(type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'insert', index(idx), type,
+ tagid(tag), *hash_kv(keys)))
+ tag
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb
new file mode 100644
index 0000000..f10ec54
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb
@@ -0,0 +1,56 @@
+#
+# tkextlib/iwidgets/watch.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Watch < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Watch
+ TkCommandNames = ['::iwidgets::watch'.freeze].freeze
+ WidgetClassName = 'Watch'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'showampm'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'clockcolor' << 'hourcolor' << 'minutecolor' <<
+ 'pivotcolor' << 'secondcolor' << 'tickcolor'
+ end
+ private :__strval_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(time=None)
+ tk_call(@path, 'show', time)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+
+ def watch(*args)
+ unless args.empty?
+ tk_call(@path, 'watch', *args)
+ end
+ component_path('canvas')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb b/jni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb
new file mode 100755
index 0000000..e2fd97b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb
@@ -0,0 +1,184 @@
+#!/usr/bin/env ruby
+#
+# Ruby/Tk extension library checker
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+TkRoot.new.withdraw # hide root window
+
+name = File.basename(__FILE__)
+
+add_path = false
+verbose = false
+
+def help_msg
+ print "Usage: #{$0} [-l] [-v] [-h] [--] [dir]\n"
+ print "\tIf dir is omitted, check the directory that this command exists.\n"
+ print "\tAvailable options are \n"
+ print "\t -l : Add dir to $LOAD_PATH\n"
+ print "\t (If dir == '<parent>/tkextlib', add <parent> also.)\n"
+ print "\t -v : Verbose mode (show reason of fail)\n"
+ print "\t -h : Show this message\n"
+ print "\t -- : End of options\n"
+end
+
+while(ARGV[0] && ARGV[0][0] == ?-)
+ case ARGV[0]
+ when '--'
+ ARGV.shift
+ break;
+ when '-l'
+ ARGV.shift
+ add_path = true
+ when '-v'
+ ARGV.shift
+ verbose = true
+ when '-h'
+ help_msg
+ exit(0)
+ else
+ print "Argument Error!! : unknown option '#{ARGV[0]}'\n"
+ help_msg
+ exit(1)
+ end
+end
+
+if ARGV[0]
+ dir = File.expand_path(ARGV[0])
+else
+ dir = File.dirname(File.expand_path(__FILE__))
+end
+
+if add_path
+ $LOAD_PATH.unshift(dir)
+ if File.basename(dir) == 'tkextlib'
+ $LOAD_PATH.unshift(File.dirname(dir))
+ end
+end
+
+print "\nRuby/Tk extension library checker\n"
+print "( Note:: This check is very simple one. Shown status may be wrong. )\n"
+print "\n check directory :: #{dir}"
+print "\n $LOAD_PATH :: #{$LOAD_PATH.inspect}\n"
+
+def get_pkg_list(file)
+ pkg_list = []
+
+ File.foreach(file){|l|
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)TkPackage\s*\.\s*require\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :package]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tcllibrary\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :library]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tclscript\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :script]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)require\s*\(?\s*(["'])((\w|\/|:)+)\1/
+ pkg = [$2, :require_ruby_lib]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ }
+
+ pkg_list
+end
+
+def check_pkg(file, verbose=false)
+ pkg_list = get_pkg_list(file)
+
+ error_list = []
+ success_list = {}
+
+ pkg_list.each{|name, type|
+ next if success_list[name]
+
+ begin
+ case type
+ when :package
+ ver = TkPackage.require(name)
+ success_list[name] = ver
+ error_list.delete_if{|n, t| n == name}
+
+ when :library
+ Tk.load_tcllibrary(name)
+ success_list[name] = :library
+ error_list.delete_if{|n, t| n == name}
+
+ when :script
+ Tk.load_tclscript(name)
+ success_list[name] = :script
+ error_list.delete_if{|n, t| n == name}
+
+ when :require_ruby_lib
+ require name
+
+ end
+ rescue => e
+ if verbose
+ error_list << [name, type, e.message]
+ else
+ error_list << [name, type]
+ end
+ end
+ }
+
+ success_list.dup.each{|name, ver|
+ unless ver.kind_of?(String)
+ begin
+ ver = TkPackage.require(name)
+ sccess_list[name] = ver
+ rescue
+ end
+ end
+ }
+
+ [success_list, error_list]
+end
+
+def subdir_check(dir, verbose=false)
+ Dir.foreach(dir){|f|
+ next if f == '.' || f == '..'
+ if File.directory?(f)
+ subdir_check(File.join(dir, f))
+ elsif File.extname(f) == '.rb'
+ path = File.join(dir, f)
+ suc, err = check_pkg(path, verbose)
+ if err.empty?
+ print 'Ready : ', path, ' : require->', suc.inspect, "\n"
+ else
+ print '*LACK : ', path, ' : require->', suc.inspect,
+ ' FAIL->', err.inspect, "\n"
+ end
+ end
+ }
+end
+
+Dir.chdir(dir)
+
+(Dir['*.rb'] - ['setup.rb', name]).each{|f|
+ subdir = File.basename(f, '.*')
+=begin
+ begin
+ # read 'setup.rb' as if the library has standard structure
+ require File.join(subdir, 'setup.rb')
+ rescue LoadError
+ # ignore error
+ end
+=end
+ print "\n"
+
+ suc, err = check_pkg(f, verbose)
+ if err.empty?
+ print 'Ready : ', f, ' : require->', suc.inspect, "\n"
+ else
+ print '*LACK : ', f, ' : require->', suc.inspect,
+ ' FAIL->', err.inspect, "\n"
+ end
+
+ subdir_check(subdir, verbose) if File.directory?(subdir)
+}
diff --git a/jni/ruby/ext/tk/lib/tkextlib/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/setup.rb
new file mode 100644
index 0000000..79facc5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before using Tk extension libraries
+#
+# If you need some setup operations for Tk extensions (for example,
+# modify the dynamic library path) required, please write the setup
+# operations in this file. This file is required at the last of
+# "require 'tk'".
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib.rb
new file mode 100644
index 0000000..2831989
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib.rb
@@ -0,0 +1,105 @@
+#
+# tcllib extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tcllib/setup.rb'
+
+err = ''
+
+# package:: autoscroll
+target = 'tkextlib/tcllib/autoscroll'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# package:: cursor
+target = 'tkextlib/tcllib/cursor'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# package:: style
+target = 'tkextlib/tcllib/style'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# autoload
+module Tk
+ module Tcllib
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ # package:: autoscroll
+ autoload :Autoscroll, 'tkextlib/tcllib/autoscroll'
+
+ # package:: ctext
+ autoload :CText, 'tkextlib/tcllib/ctext'
+
+ # package:: cursor
+ autoload :Cursor, 'tkextlib/tcllib/cursor'
+
+ # package:: datefield
+ autoload :Datefield, 'tkextlib/tcllib/datefield'
+ autoload :DateField, 'tkextlib/tcllib/datefield'
+
+ # package:: getstring
+ autoload :GetString_Dialog, 'tkextlib/tcllib/getstring'
+
+ # package:: history
+ autoload :History, 'tkextlib/tcllib/history'
+
+ # package:: ico
+ autoload :ICO, 'tkextlib/tcllib/ico'
+
+ # package:: ipentry
+ autoload :IP_Entry, 'tkextlib/tcllib/ip_entry'
+ autoload :IPEntry, 'tkextlib/tcllib/ip_entry'
+
+ # package:: khim
+ autoload :KHIM, 'tkextlib/tcllib/khim'
+
+ # package:: ntext
+ autoload :Ntext, 'tkextlib/tcllib/ntext'
+
+ # package:: Plotchart
+ autoload :Plotchart, 'tkextlib/tcllib/plotchart'
+
+ # package:: style
+ autoload :Style, 'tkextlib/tcllib/style'
+
+ # package:: swaplist
+ autoload :Swaplist_Dialog, 'tkextlib/tcllib/swaplist'
+
+ # package:: tablelist
+ autoload :Tablelist, 'tkextlib/tcllib/tablelist'
+ autoload :TableList, 'tkextlib/tcllib/tablelist'
+ autoload :Tablelist_Tile, 'tkextlib/tcllib/tablelist_tile'
+ autoload :TableList_Tile, 'tkextlib/tcllib/tablelist_tile'
+
+ # package:: tkpiechart
+ autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart'
+
+ # package:: tooltip
+ autoload :Tooltip, 'tkextlib/tcllib/tooltip'
+
+ # package:: widget
+ autoload :Widget, 'tkextlib/tcllib/widget'
+ end
+end
+
+if $VERBOSE && !err.empty?
+ warn("Warning: some sub-packages are failed to require : " + err)
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/README b/jni/ruby/ext/tk/lib/tkextlib/tcllib/README
new file mode 100644
index 0000000..441918a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/README
@@ -0,0 +1,135 @@
+
+ [ tcllib extension support files ]
+
+Tcllib includes many utilities. But currently, supports TKLib part
+only (see the following 'tcllib contents').
+
+If you request to support others, please send your message to one of
+ruby-talk/ruby-list/ruby-dev/ruby-ext mailing lists.
+
+-----<from "What is tcllib?">----------------------------
+Tcllib is a collection of utility modules for Tcl. These modules provide
+a wide variety of functionality, from implementations of standard data
+structures to implementations of common networking protocols. The intent
+is to collect commonly used function into a single library, which users
+can rely on to be available and stable.
+---------------------------------------------------------
+
+-----< tcllib contents (based on tcllib-1.6.1) >---------
+Programming tools
+ * cmdline - Procedures to process command lines and options.
+ * comm - A remote communications facility for Tcl (7.6, 8.0, and later)
+ * control - Procedures for control flow structures.
+ * fileutil - Procedures implementing some file utilities
+ * log - Procedures to log messages of libraries and applications.
+ * logger - System to control logging of events.
+ * multiplexer - One-to-many communication with sockets.
+ * snit - Snit's Not Incr Tcl
+ * snitfaq - Snit Frequently Asked Questions
+ * stooop - Object oriented extension.
+ * stoop - Simple Tcl Only Object Oriented Programming
+ * switched - stooop switched class
+ * profiler - Tcl source code profiler
+
+Mathematics
+ * math::statistics - Basic statistical functions and procedures
+ * math::calculus - Integration and ordinary differential equations
+ * math::optimize - Optimisation routines
+ * math::fuzzy - Fuzzy comparison of floating-point numbers
+ * counter - Procedures for counters and histograms
+ * combinatorics - Combinatorial functions in the Tcl Math Library
+
+Data structures
+ * struct::list - Procedures for manipulating lists
+ * struct::set - Procedures for manipulating sets
+ * struct::stack - Create and manipulate stack objects
+ * struct::queue - Create and manipulate queue objects
+ * struct::prioqueue - Create and manipulate prioqueue objects
+ * struct::skiplist - Create and manipulate skiplists
+ * struct::tree - Create and manipulate tree objects
+ * struct::graph - Create and manipulate directed graph objects
+ * struct::record - Define and create records (similar to 'C' structures)
+ * struct::matrix - Create and manipulate matrix objects
+ * struct::pool - Create and manipulate pool objects (of discrete items)
+ * report - Create and manipulate report objects
+
+Text processing
+ * expander - Procedures to process templates and expand text.
+ * base64 - Procedures to encode and decode base64
+ * yencode - encode/decoding a binary file
+ * uuencode - encode/decoding a binary file
+ * csv - Procedures to handle CSV data.
+ * inifile - Parsing of Windows INI files
+ * htmlparse - Procedures to parse HTML strings
+ * mime - Manipulation of MIME body parts
+ * Tcl MIME - generates and parses MIME body parts
+ * textutil - Procedures to manipulate texts and strings.
+ * exif - Tcl EXIF extracts and parses EXIF fields from digital images
+ * EXIF - extract and parse EXIF fields from digital images
+
+Hashes, checksums, and encryption
+ * cksum - calculate a cksum(1) compatible checksum
+ * crc16 - Perform a 16bit Cyclic Redundancy Check
+ * crc32 - Perform a 32bit Cyclic Redundancy Check
+ * des - Perform DES encryption of Tcl data
+ * md4 - MD4 Message-Digest Algorithm
+ * md5 - MD5 Message-Digest Algorithm
+ * ripemd160 - RIPEMD-160 Message-Digest Algorithm
+ * ripemd128 - RIPEMD-128 Message-Digest Algorithm
+ * md5crypt - MD5-based password encryption
+ * sha1 - Perform sha1 hashing
+ * sum - calculate a sum(1) compatible checksum
+ * soundex - Soundex
+
+Documentation tools
+ * mpexpand - Markup processor
+ * doctools - Create and manipulate doctools converter object
+ * doctoc_fmt - Specification of simple tcl markup for table of contents
+ * doctools_api - Interface specification for formatter code
+ * doctools_fmt - Specification of simple tcl markup for manpages
+ * docidx - Create and manipulate docidx converter objects
+ * docidx_api - Interface specification for index formatting code
+ * docidx_fmt - Specification of simple tcl markup for an index
+ * doctoc - Create and manipulate doctoc converter objects
+ * doctoc_api - Interface specification for toc formatting code
+ * doctools::changelog - Handle text in Emacs ChangeLog format
+ * doctools::cvs - Handle text in 'cvs log' format
+
+Networking
+ * uri - URI utilities
+ * dns - Tcl Domain Name Service Client
+ * ntp_time - Tcl Time Service Client
+ * nntp - Tcl client for the NNTP protocol
+ * pop3 - Tcl client for POP3 email protocol
+ * pop3d - Tcl POP3 server implementation
+ * pop3d::udb - Simple user database for pop3d
+ * pop3d::dbox - Simple mailbox database for pop3d
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftpd - Tcl FTP server implementation
+ * smtp - Client-side tcl implementation of the smtp protocol
+ * smtpd - Tcl SMTP server implementation
+ * irc - Create IRC connection and interface.
+
+CGI programming
+ * ncgi - Procedures to manipulate CGI values.
+ * html - Procedures to generate HTML structures
+ * javascript - Procedures to generate HTML and Java Script structures.
+
+Grammars and finite automata
+ * grammar::fa - Create and manipulate finite automatons
+ * grammar::fa::op - Operations on finite automatons
+ * grammar::dacceptor - Create and use deterministic acceptors
+ * grammar::dexec - Execute deterministic finite automatons
+
+TKLib
+ * Plotchart - Simple plotting and charting package
+ * autoscroll - Provides for a scrollbar to automatically mapped and
+ unmapped as needed
+ * ctext - An extended text widget with customizable Syntax highlighting
+ * cursor - Procedures to handle CURSOR data
+ * datefield - Tk datefield widget
+ * style - Changes default Tk look&feel
+ * ipentry - An IP address entry widget
+ * tkpiechart - Creates and dynamically updates 2D or 3D pie charts
+---------------------------------------------------------
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
new file mode 100644
index 0000000..2def59b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
@@ -0,0 +1,158 @@
+#
+# tkextlib/tcllib/autoscroll.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides for a scrollbar to automatically mapped and unmapped as needed
+#
+# (The following is the original description of the library.)
+#
+# This package allows scrollbars to be mapped and unmapped as needed
+# depending on the size and content of the scrollbars scrolled widget.
+# The scrollbar must be managed by either pack or grid, other geometry
+# managers are not supported.
+#
+# When managed by pack, any geometry changes made in the scrollbars parent
+# between the time a scrollbar is unmapped, and when it is mapped will be
+# lost. It is an error to destroy any of the scrollbars siblings while the
+# scrollbar is unmapped. When managed by grid, if anything becomes gridded
+# in the same row and column the scrollbar occupied it will be replaced by
+# the scrollbar when remapped.
+#
+# This package may be used on any scrollbar-like widget as long as it
+# supports the set subcommand in the same style as scrollbar. If the set
+# subcommand is not used then this package will have no effect.
+#
+
+require 'tk'
+require 'tk/scrollbar'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Autoscroll
+ PACKAGE_NAME = 'autoscroll'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('autoscroll')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
+ end
+
+ def self.autoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+
+ def self.unautoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+ end
+ end
+end
+
+module Tk
+ module Scrollable
+ def autoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ def unautoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ end
+end
+
+class Tk::Scrollbar
+ def autoscroll
+ # Arranges for the already existing scrollbar to be mapped
+ # and unmapped as needed.
+ #tk_call_without_enc('::autoscroll::autoscroll', @path)
+ Tk::Tcllib::Autoscroll.autoscroll(self)
+ self
+ end
+ def unautoscroll
+ # Returns the scrollbar to its original static state.
+ #tk_call_without_enc('::autoscroll::unautoscroll', @path)
+ Tk::Tcllib::Autoscroll.unautoscroll(self)
+ self
+ end
+end
+
+# TkPackage.require('autoscroll', '1.0')
+# TkPackage.require('autoscroll', '1.1')
+TkPackage.require('autoscroll')
+
+module Tk
+ module Tcllib
+ class << Autoscroll
+ undef not_available
+ end
+
+ module Autoscroll
+ extend TkCore
+ def self.autoscroll(win)
+ tk_call_without_enc('::autoscroll::autoscroll', win.path)
+ end
+
+ def self.unautoscroll(win)
+ tk_call_without_enc('::autoscroll::unautoscroll', win.path)
+ end
+
+ def self.wrap
+ # v1.1
+ tk_call_without_enc('::autoscroll::wrap')
+ end
+
+ def self.unwrap
+ # v1.1
+ tk_call_without_enc('::autoscroll::unwrap')
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb
new file mode 100644
index 0000000..b6843df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb
@@ -0,0 +1,55 @@
+#
+# tkextlib/tcllib/calendar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * calendar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::calendar', '0.9')
+TkPackage.require('widget::calendar')
+
+module Tk::Tcllib
+ module Widget
+ class Calendar < TkCanvas
+ PACKAGE_NAME = 'widget::calendar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::calendar')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Calendar
+ TkCommandNames = ['::widget::calendar'.freeze].freeze
+
+ def __boolval_optkeys
+ super() << 'showpast'
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def get(what = 'all')
+ tk_send('get', what)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb
new file mode 100644
index 0000000..ba87cd3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb
@@ -0,0 +1,36 @@
+#
+# tkextlib/tcllib/canvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# *
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::canvas_sqmap', '0.2')
+TkPackage.require('widget::canvas_sqmap')
+
+module Tk::Tcllib
+ module Widget
+ class Canvas_Sqmap < Canvas
+ TkCommandNames = ['::widget::canvas_sqmap'.freeze].freeze
+
+ def image_set(cell, img)
+ tk_send('image', 'set', cell, img)
+ self
+ end
+
+ def image_unset(cell)
+ tk_send('image', 'unset', cell)
+ self
+ end
+
+ def flush
+ tk_send('flush')
+ self
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb
new file mode 100644
index 0000000..f4ffb48
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/tcllib/canvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# *
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::canvas_zoom', '0.1')
+TkPackage.require('widget::canvas_zoom')
+
+module Tk::Tcllib
+ module Widget
+ class Canvas_Zoom < Canvas
+ TkCommandNames = ['::widget::canvas_zoom'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb
new file mode 100644
index 0000000..ddb0340
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb
@@ -0,0 +1,151 @@
+#
+# tkextlib/tcllib/chatwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * chatwidget - Provides a multi-paned view suitable for display of
+# chat room or irc channel information
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('chatwidget', '1.1.0')
+TkPackage.require('chatwidget')
+
+module Tk::Tcllib
+ class ChatWidget < TkText
+ PACKAGE_NAME = 'chatwidget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('chatwidget')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ChatWidget
+ TkCommandNames = ['::chatwidget::chatwidget'.freeze].freeze
+
+ def show_topic
+ tk_send_without_enc('topic', 'show')
+ self
+ end
+
+ def hide_topic
+ tk_send_without_enc('topic', 'hide')
+ self
+ end
+
+ def set_topic(topic)
+ tk_send('topic', 'set', topic)
+ end
+
+ def list_name
+ tk_split_simplelist(tk_send('name', 'list'))
+ end
+
+ def list_name_full
+ tk_split_simplelist(tk_send('name', 'list')).map{|lst|
+ nick, *opts = tk_split_simplelist(lst)
+ h_opt = {}
+ opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)}
+ [nick, h_opt]
+ }
+ end
+
+ def add_name(nick, opts={})
+ tk_send('name', 'add', nick, *(hash_kv(opts)))
+ end
+
+ def delete_name(nick)
+ tk_send('name', 'delete', nick)
+ end
+
+ def get_name(nick)
+ lst = tk_send('name', 'get', nick)
+ return nil if lst.empty?
+ nick, *opts = tk_split_simplelist(lst)
+ h_opt = {}
+ opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)}
+ [nick, h_opt]
+ end
+
+ def message(msg, opts={})
+ tk_send('message', msg, *(hash_kv(opts)))
+ self
+ end
+
+ def _parse_hook_list(lst)
+ tk_split_simplelist(lst).map{|hook|
+ cmd, prior = tk_split_simplelist(hook)
+ [procedure(cmd), number(prior)]
+ }
+ end
+ private :_parse_hook_list
+
+ def hook_add(type, *args, &blk) # args -> [prior, cmd], [prior], [cmd]
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+
+ if prior = args.shift
+ if !prior.kind_of?(Numeric)
+ cmd = prior
+ if (prior = args.shift) && !prior.kind_of?(Numeric) # error
+ args.unshift(prior)
+ end
+ args.unshift(cmd)
+ end
+ prior ||= 50 # default priority
+ end
+
+ cmd = args.shift || blk
+
+ fail ArgumentError, "invalid arguments" unless args.empty?
+ fail ArgumentError, "no callback is given" unless cmd
+
+ _parse_hook_list(tk_send('hook', 'add', type, cmd, prior))
+ end
+
+ def hook_remove(type, cmd)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ _parse_hook_list(tk_send('hook', 'remove', type, cmd))
+ end
+
+ def hook_run(type, *cmd_args)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ tk_send('hook', 'run', type, *cmd_args)
+ end
+
+ def hook_list(type)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ _parse_hook_list(tk_send('hook', 'list', type))
+ end
+
+ def show_names
+ tk_send('names', 'show')
+ self
+ end
+
+ def hide_names
+ tk_send('names', 'hide')
+ self
+ end
+
+ def names_widget
+ window(tk_send('names'))
+ end
+
+ def entry_widget
+ window(tk_send('entry'))
+ end
+
+ def chat_widget
+ window(tk_send('chat'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb
new file mode 100644
index 0000000..49b5361
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb
@@ -0,0 +1,117 @@
+#
+# tkextlib/tcllib/crosshair.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Crosshairs for Tk canvas
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('crosshair', '1.0.2')
+TkPackage.require('crosshair')
+
+module Tk::Tcllib
+ module Crosshair
+ PACKAGE_NAME = 'crosshair'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('crosshair')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Crosshair
+ include TkCore
+ TkCommandNames = ['::crosshair::crosshair'.freeze].freeze
+
+ def self.crosshair(w, keys={})
+ Tk.tk_call('::crosshair::crosshair', w, *hash_kv(keys))
+ w
+ end
+ def self.on(w, keys={})
+ self.crosshair(w, keys)
+ end
+
+ def self.off(w)
+ Tk.tk_call('::crosshair::off', w)
+ w
+ end
+
+ def self.track_on(w, &b)
+ Tk.tk_call('::crosshair::track_on', w, b)
+ w
+ end
+
+ def self.track_off(w)
+ Tk.tk_call('::crosshair::track_off', w)
+ w
+ end
+end
+
+class << Tk::Tcllib::Crosshair
+ include TkComm
+ include TkCanvasItemConfig
+
+ def __item_methodcall_optkeys(id)
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ def __item_config_cmd(id)
+ # maybe need to override
+ ['::crosshair::configure', id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def confugure(w, slot, value=None)
+ itemconfigure(w, slot, value)
+ end
+ def confuginfo(w, slot = nil)
+ itemconfiginfo(w, slot)
+ end
+ def current_configinfo(w, slot = nil)
+ current_itemconfiginfo(w, slot)
+ end
+ def cget(w, slot)
+ current_itemconfiginfo(w, slot).values[0]
+ end
+end
+
+module Tk::Tcllib::Crosshair
+ def crosshair_on(keys={})
+ Tk::Tcllib::Crosshair.on(self, keys)
+ end
+ def crosshair_off
+ Tk::Tcllib::Crosshair.off(self)
+ end
+ def crosshair_track_on(&b)
+ Tk::Tcllib::Crosshair.track_on(self, &b)
+ end
+ def crosshair_track_off
+ Tk::Tcllib::Crosshair.track_off(self)
+ end
+ def crosshair_configure(*args)
+ Tk::Tcllib::Crosshair.configure(self, *args)
+ end
+ def crosshair_configinfo(slot = nil)
+ Tk::Tcllib::Crosshair.configinfo(self, slot)
+ end
+ def crosshair_current_configinfo(slot = nil)
+ Tk::Tcllib::Crosshair.current_configinfo(self, slot)
+ end
+ def crosshair_cget(slot)
+ Tk::Tcllib::Crosshair.cget(self, slot)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb
new file mode 100644
index 0000000..308847c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb
@@ -0,0 +1,160 @@
+#
+# tkextlib/tcllib/ctext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Overloads the text widget and provides new commands
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ctext', '3.1')
+TkPackage.require('ctext')
+
+module Tk
+ module Tcllib
+ class CText < Tk::Text
+ PACKAGE_NAME = 'ctext'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ctext')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::CText
+ TkCommandNames = ['ctext'.freeze].freeze
+ WidgetClassName = 'Ctext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'linemapfg' << 'linemapbg' <<
+ 'linemap_select_fg' << 'linemap_select_bg'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'highlight' << 'linemap_markable'
+ end
+ private :__boolval_optkeys
+
+ def append(*args)
+ tk_send('append', *args)
+ end
+
+ def copy
+ tk_send('copy')
+ end
+
+ def cut
+ tk_send('cut')
+ end
+
+ def fast_delete(*args)
+ tk_send('fastdelete', *args)
+ end
+
+ def fast_insert(*args)
+ tk_send('fastinsert', *args)
+ end
+
+ def highlight(*args)
+ tk_send('highlight', *args)
+ end
+
+ def paste
+ tk_send('paste')
+ end
+
+ def edit(*args)
+ tk_send('edit', *args)
+ end
+
+ def add_highlight_class(klass, col, *keywords)
+ tk_call('ctext::addHighlightClass', @path, klass, col, keywords.flatten)
+ self
+ end
+
+ def add_highlight_class_for_special_chars(klass, col, *chrs)
+ tk_call('ctext::addHighlightClassForSpecialChars',
+ @path, klass, col, chrs.join(''))
+ self
+ end
+
+ def add_highlight_class_for_regexp(klass, col, tcl_regexp)
+ tk_call('ctext::addHighlightClassForRegexp',
+ @path, klass, col, tcl_regexp)
+ self
+ end
+
+ def add_highlight_class_with_only_char_start(klass, col, chr)
+ tk_call('ctext::addHighlightClassWithOnlyCharStart',
+ @path, klass, col, chr)
+ self
+ end
+
+ def clear_highlight_classes
+ tk_call('ctext::clearHighlightClasses', @path)
+ self
+ end
+
+ def get_highlight_classes
+ tk_split_simplelist(tk_call('ctext::getHighlightClasses', @path))
+ end
+
+ def delete_highlight_class(klass)
+ tk_call('ctext::deleteHighlightClass', @path, klass)
+ self
+ end
+
+ def enable_C_comments
+ tk_call('ctext::enableComments', @path)
+ self
+ end
+
+ def disable_C_comments
+ tk_call('ctext::disableComments', @path)
+ self
+ end
+
+ def find_next_char(idx, chr)
+ tk_call('ctext::findNextChar', @path, idx, chr)
+ end
+
+ def find_next_space(idx)
+ tk_call('ctext::findNextSpace', @path, idx)
+ end
+
+ def find_previous_space(idx)
+ tk_call('ctext::findPreviousSpace', @path, idx)
+ end
+
+ def set_update_proc(cmd=Proc.new)
+ tk_call('proc', 'ctext::update', '', cmd)
+ self
+ end
+
+ def modified?(mode)
+ bool(tk_call('ctext::modified', @path, mode))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb
new file mode 100644
index 0000000..5c47f97
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb
@@ -0,0 +1,97 @@
+#
+# tkextlib/tcllib/cursor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Procedures to handle CURSOR data
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Cursor
+ PACKAGE_NAME = 'cursor'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('cursor')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
+ end
+
+ def self.cursor_display(win=None)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_propagate(win, cursor)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ Tk::Tcllib::Cursor.not_available
+ end
+ end
+ end
+
+ def self.cursor_display(parent=None)
+ # Pops up a dialog with a listbox containing all the cursor names.
+ # Selecting a cursor name will display it in that dialog.
+ # This is simply for viewing any available cursors on the platform .
+ #tk_call_without_enc('::cursor::display', parent)
+ Tk::Tcllib::Cursor.cursor_display(parent)
+ end
+end
+
+class TkWindow
+ def cursor_propagate(cursor)
+ # Sets the cursor for self and all its descendants to cursor.
+ #tk_call_without_enc('::cursor::propagate', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_propagate(self, cursor)
+ end
+ def cursor_restore(cursor = None)
+ # Restore the original or previously set cursor for self and all its
+ # descendants. If cursor is specified, that will be used if on any
+ # widget that did not have a preset cursor (set by a previous call
+ # to TkWindow#cursor_propagate).
+ #tk_call_without_enc('::cursor::restore', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_restore(self, cursor)
+ end
+end
+
+# TkPackage.require('cursor', '0.1')
+TkPackage.require('cursor')
+
+module Tk
+ module Tcllib
+ class << Cursor
+ undef not_available
+ end
+
+ module Cursor
+ extend TkCore
+ def self.cursor_display(win=None)
+ tk_call_without_enc('::cursor::display', _epath(win))
+ end
+
+ def self.cursor_propagate(win, cursor)
+ #tk_call_without_enc('::cursor::propagate', win.path, cursor)
+ tk_call_without_enc('::cursor::propagate', _epath(win), cursor)
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ #tk_call_without_enc('::cursor::restore', win.path, cursor)
+ tk_call_without_enc('::cursor::restore', _epath(win), cursor)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb
new file mode 100644
index 0000000..77038d9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/tcllib/dateentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * dateentry widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::dateentry', '0.91')
+TkPackage.require('widget::dateentry')
+
+module Tk::Tcllib
+ module Widget
+ class Dateentry < Tk::Tile::TEntry
+ PACKAGE_NAME = 'widget::dateentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::dateentry')
+ rescue
+ ''
+ end
+ end
+ end
+ DateEntry = Dateentry
+ end
+end
+
+class Tk::Tcllib::Widget::Dateentry
+ TkCommandNames = ['::widget::dateentry'.freeze].freeze
+
+ def __strval_optkeys
+ super() << ['dateformat']
+ end
+ private :__strval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def post
+ tk_send('post')
+ self
+ end
+
+ def unpost
+ tk_send('unpost')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb
new file mode 100644
index 0000000..4c2eae7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb
@@ -0,0 +1,57 @@
+#
+# tkextlib/tcllib/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Tk datefield widget
+#
+# (The following is the original description of the library.)
+#
+# The datefield package provides the datefield widget which is an enhanced
+# text entry widget for the purpose of date entry. Only valid dates of the
+# form MM/DD/YYYY can be entered.
+#
+# The datefield widget is, in fact, just an entry widget with specialized
+# bindings. This means all the command and options for an entry widget apply
+# equally here.
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('datefield', '0.1')
+TkPackage.require('datefield')
+
+module Tk
+ module Tcllib
+ class Datefield < Tk::Entry
+ PACKAGE_NAME = 'datefield'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('datefield')
+ rescue
+ ''
+ end
+ end
+ end
+ DateField = Datefield
+ end
+end
+
+class Tk::Tcllib::Datefield
+ TkCommandNames = ['::datefield::datefield'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb
new file mode 100644
index 0000000..d24ba9d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb
@@ -0,0 +1,224 @@
+#
+# tkextlib/tcllib/diagrams.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Draw diagrams
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Diagrams', '0.3')
+TkPackage.require('Diagrams')
+
+module Tk::Tcllib
+ module Diagrams
+ PACKAGE_NAME = 'Diagrams'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Diagrams')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class << Tk::Tcllib::Diagrams
+ include TkCore
+
+ def drawin(canvas)
+ tk_call('::Diagrams::drawin', canvas)
+ canvas
+ end
+ alias draw_in drawin
+
+ def saveps(filename)
+ tk_call('::Diagrams::saveps', filename)
+ filename
+ end
+ alias save_ps saveps
+
+ def direction(dir)
+ tk_call('::Diagrams::direction', dir)
+ dir
+ end
+
+ def currentpos(pos)
+ list(tk_call('::Diagrams::currentpos', pos))
+ end
+ alias current_pos currentpos
+ alias currentpos= currentpos
+ alias current_pos= currentpos
+
+ def getpos(anchor, obj)
+ list(tk_call('::Diagrams::getpos', anchor, obj))
+ end
+ alias get_pos getpos
+
+ def position(x, y)
+ list(tk_call('::Diagrams::position', x, y))
+ end
+
+ def box(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::box', text, width, height))
+ else
+ list(tk_call('::Diagrams::box', text))
+ end
+ end
+
+ def plaintext(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::plaintext', text, width, height))
+ else
+ list(tk_call('::Diagrams::plaintext', text))
+ end
+ end
+
+ def circle(text, radius=nil)
+ if radius
+ list(tk_call('::Diagrams::circle', text, radius))
+ else
+ list(tk_call('::Diagrams::circle', text))
+ end
+ end
+
+ def slanted(text, width=nil, height=nil, angle=nil)
+ if width || height || angle
+ width = '' unless width
+ height = '' unless height
+ if angle
+ list(tk_call('::Diagrams::slanted', text, width, height, angle))
+ else
+ list(tk_call('::Diagrams::slanted', text, width, height))
+ end
+ else
+ list(tk_call('::Diagrams::slanted', text))
+ end
+ end
+
+ def diamond(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::diamond', text, width, height))
+ else
+ list(tk_call('::Diagrams::diamond', text))
+ end
+ end
+
+ def drum(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::drum', text, width, height))
+ else
+ list(tk_call('::Diagrams::drum', text))
+ end
+ end
+
+ def arrow(text=nil, length=nil, head=nil)
+ if length || head
+ text = '' unless text
+ length = '' unless length
+ list(tk_call('::Diagrams::arrow', text, length, head))
+ else
+ if text
+ list(tk_call('::Diagrams::arrow', text))
+ else
+ list(tk_call('::Diagrams::arrow'))
+ end
+ end
+ end
+
+ def line(*args)
+ ary = []
+ args.each{|arg|
+ if arg.kind_of?(Array) && arg.length == 2 # [length, angle]
+ ary.concat arg
+ else # ["POSITION", x, y] or length or angle
+ ary << arg
+ end
+ }
+ list(tk_call('::Diagrams::line', *ary))
+ end
+
+ def bracket(dir, dist, from_pos, to_pos)
+ list(tk_call('::Diagrams::bracket', dir, dist, from_pos, to_pos))
+ end
+
+ def attach(anchor=None)
+ tk_call('::Diagrams::attach', anchor)
+ end
+
+ def color(name=None)
+ tk_call('::Diagrams::color', name)
+ end
+
+ def fillcolor(name=None)
+ tk_call('::Diagrams::fillcolor', name)
+ end
+
+ def textcolor(name=None)
+ tk_call('::Diagrams::textcolor', name)
+ end
+
+ def usegap(mode=None)
+ bool(tk_call('::Diagrams::usegap', mode))
+ end
+ alias use_gap usegap
+
+ def xgap(val=None)
+ number(tk_call('::Diagrams::xgap', val))
+ end
+
+ def ygap(val=None)
+ number(tk_call('::Diagrams::ygap', val))
+ end
+
+ def textfont(fnt=None)
+ tk_call('::Diagrams::textfont', fnt)
+ end
+
+ def linewidth(pixels=None)
+ number(tk_call('::Diagrams::linewidth', pixels))
+ end
+
+ def linestyle(style=None)
+ tk_call('::Diagrams::linestyle', style)
+ end
+
+ def pushstate
+ tk_call('::Diagrams::pushstate')
+ end
+ alias push_state pushstate
+
+ def popstate
+ tk_call('::Diagrams::popstate')
+ end
+ alias pop_state popstate
+
+ def computepos
+ list(tk_call('::Diagrams::computepos'))
+ end
+ alias compute_pos computepos
+
+ def boxcoords(x1, y1, x2, y2)
+ list(tk_call('::Diagrams::boxcoords', x1, y1, x2, y2))
+ end
+
+ def moveobject(obj)
+ list(tk_call('::Diagrams::moveobject', obj))
+ end
+ alias move_object moveobject
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb
new file mode 100644
index 0000000..86a0ef2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb
@@ -0,0 +1,84 @@
+#
+# tkextlib/tcllib/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Generic dialog widget (themed)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::dialog', '1.2')
+TkPackage.require('widget::dialog')
+
+module Tk::Tcllib
+ module Widget
+ class Dialog < TkWindow
+ PACKAGE_NAME = 'widget::dialog'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::dialog')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Dialog
+ TkCommandNames = ['::widget::dialog'.freeze].freeze
+
+ def __boolval_optkeys
+ ['separator', 'synchronous', 'transient']
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def add(what, *args)
+ window(tk_send('add', *args))
+ end
+
+ def get_frame
+ window(tk_send('getframe'))
+ end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+
+ def display
+ tk_send('display')
+ self
+ end
+ alias show display
+
+ def cancel
+ tk_send('cancel')
+ self
+ end
+
+ def close(reason = None)
+ tk_send('close', reason)
+ end
+
+ def withdraw
+ tk_send('withdraw')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb
new file mode 100644
index 0000000..48711d3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb
@@ -0,0 +1,134 @@
+#
+# tkextlib/tcllib/getstring.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A dialog which consists of an Entry, OK, and Cancel buttons.
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('getstring', '0.1')
+TkPackage.require('getstring')
+
+module Tk::Tcllib
+ class GetString_Dialog < TkWindow
+ PACKAGE_NAME = 'getstring'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('getstring')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+
+class Tk::Tcllib::GetString_Dialog
+ TkCommandNames = ['::getstring::tk_getString'.freeze].freeze
+ WidgetClassName = 'TkSDialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def initialize(*args) # args = (parent=nil, text='', keys=nil)
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ text = args.pop
+ @keys = _symbolkey2str(keys)
+ args.push(keys)
+ else
+ text = keys
+ @keys = {}
+ end
+ if text
+ @text = text.dup
+ else
+ @text = ''
+ end
+
+ @variable = TkVariable.new
+ @status = nil
+
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ @variable.value = ''
+ @status = bool(tk_call(self.class::TkCommandNames[0],
+ @path, @variable, @text, *hash_kv(@keys)))
+ end
+ alias display show
+
+ def status
+ @status
+ end
+
+ def value
+ @variable.value
+ end
+
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'text'
+ @text
+ else
+ @keys[slot]
+ end
+ end
+ def cget(slot)
+ cget_strict(slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ if slot == 'text'
+ @text = value.to_s
+ else
+ @keys[slot] = value
+ end
+ else
+ if slot == 'text'
+ @text = ''
+ else
+ @keys.delete(slot)
+ end
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ [ slot, nil, nil, nil, ( (slot == 'text')? @text: @keys[slot] ) ]
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
+ << [ 'text', nil, nil, nil, @text ]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
new file mode 100644
index 0000000..a01a4eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/tcllib/history.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides a history for Entry widgets
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('history', '0.1')
+TkPackage.require('history')
+
+module Tk::Tcllib
+ module History
+ PACKAGE_NAME = 'history'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('history')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::History
+ extend TkCore
+
+ def self.init(entry, length=None)
+ tk_call_without_enc('::history::init', entry.path, length)
+ entry.extend(self) # add methods to treat history to the entry widget
+ end
+
+ def self.remove(entry)
+ tk_call_without_enc('::history::remove', entry.path)
+ entry
+ end
+
+ def history_remove
+ tk_call_without_enc('::history::remove', @path)
+ self
+ end
+
+ def history_add(text)
+ tk_call('::history::add', @path, text)
+ self
+ end
+
+ def history_get
+ simplelist(tk_call_without_enc('::history::get', @path))
+ end
+
+ def history_clear
+ tk_call_without_enc('::history::clear', @path)
+ self
+ end
+
+ def history_configure(opt, value)
+ tk_call('::history::configure', @path, opt, value)
+ self
+ end
+
+ def history_configinfo(opt)
+ tk_call('::history::configure', @path, opt)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb
new file mode 100644
index 0000000..36a32c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb
@@ -0,0 +1,146 @@
+#
+# tkextlib/tcllib/ico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Reading and writing windows icons
+#
+
+require 'tk'
+require 'tk/image'
+#require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ico', '0.3')
+TkPackage.require('ico')
+
+module Tk
+ module Tcllib
+ class ICO < TkImage
+ PACKAGE_NAME = 'ico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ICO
+ def self.list(file, keys=nil)
+ tk_split_list(tk_call_without_enc('::ico::getIconList', file,
+ *hash_kv(keys, true)))
+ end
+
+ def self.icons(file, keys=nil)
+ tk_split_simplelist(tk_call_without_enc('::ico::icons', file,
+ *hash_kv(keys, true))).map{|elem|
+ num_or_str(elem)
+ }
+ end
+
+ def self.get_members(file, name, keys=nil)
+ tk_split_simplelist(tk_call_without_enc('::ico::getMembers', file, name,
+ *hash_kv(keys, true))).map{|elem|
+ name, width, height, bpp = tk_split_simplelist(elem)
+ [name, number(width), number(height), number(bpp)]
+ }
+ end
+
+ def self.get(file, index, keys=nil)
+ tk_call_without_enc('::ico::getIcon', file, index, *hash_kv(keys, true))
+ end
+ def self.get_icon(*args)
+ get(*args)
+ end
+
+ def self.get_by_name(file, name, keys=nil)
+ tk_call_without_enc('::ico::getIconByName', file, name,
+ *hash_kv(keys, true))
+ end
+ def self.get_icon_by_name(*args)
+ get_by_name(*args)
+ end
+
+ def self.get_fileicon(file, keys=nil)
+ tk_call_without_enc('::ico::getFileIcon', file, *hash_kv(keys, true))
+ end
+
+ def self.get_image(file, index, keys={})
+ keys = _symbolkey2str(keys)
+ keys.delete('format')
+ self.new(file, index, keys)
+ end
+
+ def self.get_data(file, index, keys={})
+ keys['format'] = 'data'
+ tk_split_list(tk_call_without_enc('::ico::getIcon', file, index,
+ *hash_kv(keys, true)))
+ end
+
+ def self.write(file, index, depth, data, keys=nil)
+ tk_call_without_enc('::ico::writeIcon', file, index, depth, data,
+ *hash_kv(keys, true))
+ end
+
+ def self.copy(from_file, from_index, to_file, to_index, keys=nil)
+ tk_call_without_enc('::ico::copyIcon',
+ from_file, from_index, to_file, to_index,
+ *hash_kv(keys, true))
+ end
+
+ def self.exe_to_ico(exe_file, ico_file, keys=nil)
+ tk_call_without_enc('::ico::copyIcon', exe_file, ico_file,
+ *hash_kv(keys, true))
+ end
+
+ def self.clear_cache(file=None)
+ tk_call_without_enc('::ico::clearCache', file)
+ end
+
+ def self.transparent_color(image, color)
+ if image.kind_of?(Array)
+ tk_split_list(tk_call_without_enc('::ico::transparentColor',
+ image, color))
+ else
+ tk_call_without_enc('::ico::transparentColor', image, color)
+ end
+ end
+
+ def self.show(file, keys=nil)
+ tk_call_without_enc('::ico::Show', file, *hash_kv(keys, true))
+ end
+
+ ###########################
+
+ def initialize(file, index, keys=nil)
+ keys = _symbolkey2str(keys)
+ if keys.key?('name')
+ @path = keys['name'].to_s
+ else
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
+ end
+ tk_call_without_enc('::ico::getIcon', file, index, '-name', @path,
+ '-format', 'image', *hash_kv(keys, true))
+ Tk_IMGTBL[@path] = self
+ end
+
+ def write(file, index, depth, keys=nil)
+ Tk::Tcllib::ICO.write(file, index, depth, @path, keys=nil)
+ self
+ end
+
+ def transparent_color(color)
+ tk_call_without_enc('::ico::transparentColor', @path, color)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
new file mode 100644
index 0000000..4878cc3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
@@ -0,0 +1,75 @@
+#
+# tkextlib/tcllib/ip_entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * An IP address entry widget
+#
+# (The following is the original description of the library.)
+#
+# This package provides a widget for the entering of a IP address.
+# It guarantees a valid address at all times.
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ipentry', '0.1')
+TkPackage.require('ipentry')
+
+module Tk
+ module Tcllib
+ class IP_Entry < Tk::Entry
+ PACKAGE_NAME = 'ipentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ipentry')
+ rescue
+ ''
+ end
+ end
+ end
+ IPEntry = IP_Entry
+
+ class IP_Entry6 < IP_Entry
+ end
+ IPEntry6 = IP_Entry6
+ IP6_Entry = IP_Entry6
+ end
+end
+
+class Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry'.freeze].freeze
+ WidgetClassName = 'IPEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'fg' << 'bg' << 'insertbackground'
+ end
+ private :__strval_optkeys
+
+ def complete?
+ bool(tk_send_without_enc('complete'))
+ end
+
+ def insert(*ip)
+ tk_send_without_enc('insert', array2tk_list(ip.flatten))
+ end
+end
+
+class Tk::Tcllib::IP_Entry6 < Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry6'.freeze].freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb
new file mode 100644
index 0000000..5dc2130
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/tcllib/khim.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Kevin's Hacky Input Method
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('khim', '1.0')
+TkPackage.require('khim')
+
+module Tk::Tcllib
+ class KHIM < TkToplevel
+ PACKAGE_NAME = 'khim'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('khim')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::KHIM
+ TkCommandNames = ['::khim::getOptions'.freeze].freeze
+
+ def self.get_options(parent='')
+ path = parent + '.tcllib_widget_khim_dialog'
+ self.new(:widgetname => path)
+ end
+
+ def self.get_config #=> cmd_string
+ Tk.tk_call_without_enc('::khim::getConfig')
+ end
+
+ def self.set_config(*args)
+ if args.length == 1
+ # cmd_string generated by
+ #Tk.ip_eval_without_enc(cmd_string)
+ Tk.ip_eval(cmd_string)
+ else
+ # args for setConfig command
+ #Tk.tk_call_without_enc('::khim::setConfig', *args)
+ Tk.tk_call('::khim::setConfig', *args)
+ end
+ end
+
+ def self.showHelp
+ Tk::Tcllib::KHIM::Help.new
+ end
+
+ def create_self(keys=None)
+ @db_class = @classname = nil
+ super(None) # ignore keys
+ end
+end
+
+class Tk::Tcllib::KHIM::Help < TkToplevel
+ TkCommandNames = ['::khim::showHelp'.freeze].freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb
new file mode 100644
index 0000000..f1eb2f2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb
@@ -0,0 +1,47 @@
+#
+# tkextlib/tcllib/menuentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * menuentry widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::menuentry', '1.0')
+TkPackage.require('widget::menuentry')
+
+module Tk::Tcllib
+ module Widget
+ class Menuentry < Tk::Tile::TEntry
+ PACKAGE_NAME = 'widget::menuentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::menuentry')
+ rescue
+ ''
+ end
+ end
+ end
+ MenuEntry = Menuentry
+ end
+end
+
+class Tk::Tcllib::Widget::Menuentry
+ TkCommandNames = ['::widget::menuentry'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb
new file mode 100644
index 0000000..7888ed4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb
@@ -0,0 +1,146 @@
+#
+# tkextlib/tcllib/ntext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Ntext bindtag
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ntext', '0.81')
+TkPackage.require('ntext')
+
+module Tk::Tcllib
+ Ntext = TkBindTag.new_by_name('Ntext')
+end
+
+# variables
+Tk::Tcllib::Ntext.instance_eval{
+ # boolean
+ @classicAnchor = TkVarAccess.new('::ntext::classicAnchor')
+ @classicExtras = TkVarAccess.new('::ntext::classicExtras')
+ @classicMouseSelect = TkVarAccess.new('::ntext::classicMouseSelect')
+ @classicWordBreak = TkVarAccess.new('::ntext::classicWordBreak')
+ @classicWrap = TkVarAccess.new('::ntext::classicWrap')
+ @overwrite = TkVarAccess.new('::ntext::overwrite')
+
+ # regexp
+ @newWrapRegexp = TkVarAccess.new('::ntext::newWrapRegexp')
+
+ # variables (advanced use)
+ @tcl_match_wordBreakAfter = TkVarAccess.new('::ntext::tcl_match_wordBreakAfter')
+ @tcl_match_wordBreakBefore = TkVarAccess.new('::ntext::tcl_match_wordBreakBefore')
+ @tcl_match_endOfWord = TkVarAccess.new('::ntext::tcl_match_endOfWord')
+ @tcl_match_startOfNextWord = TkVarAccess.new('::ntext::tcl_match_startOfNextWord')
+ @tcl_match_startOfPreviousWord = TkVarAccess.new('::ntext::tcl_match_startOfPreviousWord')
+}
+
+class << Tk::Tcllib::Ntext
+ def wrapIndent(txt, *args)
+ TK.tk_call('::next::wrapIndent', txt, *args)
+ end
+
+ def initializeMatchPatterns
+ TK.tk_call('::next::initializeMatchPatterns')
+ self
+ end
+
+ def createMatchPatterns(*args)
+ TK.tk_call('::next::createMatchPatterns', *args)
+ self
+ end
+
+ # functions (advanced use)
+ #ntext::new_wordBreakAfter
+ #ntext::new_wordBreakBefore
+ #ntext::new_endOfWord
+ #ntext::new_startOfNextWord
+ #ntext::new_startOfPreviousWord
+
+ # accessor
+ def classicAnchor
+ @classicAnchor.bool
+ end
+ def classicAnchor=(mode)
+ @classicAnchor.bool = mode
+ end
+
+ def classicExtras
+ @classicExtras.bool
+ end
+ def classicExtras=(mode)
+ @classicExtras.bool = mode
+ end
+
+ def classicMouseSelect
+ @classicMouseSelect.bool
+ end
+ def classicMouseSelect=(mode)
+ @classicMouseSelect.bool = mode
+ end
+
+ def classicWordBreak
+ @classicWordBreak.bool
+ end
+ def classicWordBreak=(mode)
+ @classicWordBreak.bool = mode
+ end
+
+ def classicWrap
+ @classicWrap.bool
+ end
+ def classicWrap=(mode)
+ @classicWrap.bool = mode
+ end
+
+ def overwrite
+ @overwrite.bool
+ end
+ def overwrite=(mode)
+ @classic.bool = mode
+ end
+
+ def newWrapRegexp
+ @newWrapRegexp.value
+ end
+ def newWrapRegexp=(val)
+ @newWrapRegexp.value = val
+ end
+
+ def tcl_match_wordBreakAfter
+ @tcl_match_wordBreakAfter.value
+ end
+ def tcl_match_wordBreakAfter=(val)
+ @tcl_match_wordBreakAfter.value = val
+ end
+
+ def tcl_match_wordBreakBefore
+ @tcl_match_wordBreakBefore.value
+ end
+ def tcl_match_wordBreakBefore=(val)
+ @tcl_match_wordBreakBefore.value = val
+ end
+
+ def tcl_match_endOfWord
+ @tcl_match_endOfWord.value
+ end
+ def tcl_match_endOfWord=(val)
+ @tcl_match_endOfWord.value = val
+ end
+
+ def tcl_match_startOfNextWord
+ @tcl_match_startOfNextWord.value
+ end
+ def tcl_match_startOfNextWord=(val)
+ @tcl_match_startOfNextWord.value = val
+ end
+
+ def tcl_match_startOfPreviousWord
+ @tcl_match_startOfPreviousWord.value
+ end
+ def tcl_match_startOfPreviousWord=(val)
+ @tcl_match_startOfPreviousWord.value = val
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb
new file mode 100644
index 0000000..020c51c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb
@@ -0,0 +1,78 @@
+#
+# tkextlib/tcllib/panelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create PanelFrame widgets.
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::panelframe', '1.0')
+TkPackage.require('widget::panelframe')
+
+module Tk::Tcllib
+ module Widget
+ class PanelFrame < TkWindow
+ PACKAGE_NAME = 'widget::panelframe'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::panelframe')
+ rescue
+ ''
+ end
+ end
+ end
+ Panelframe = PanelFrame
+ end
+end
+
+class Tk::Tcllib::Widget::PanelFrame
+ TkCommandNames = ['::widget::panelframe'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def add(what, *args)
+ window(tk_send('add', *args))
+ end
+
+ #def get_frame
+ # window(tk_send('getframe'))
+ #end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+ def remove_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins)
+ tk_send('delete', *wins)
+ self
+ end
+
+ def items
+ simplelist(tk_send('items')).collect!{|w| window(w)}
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb
new file mode 100644
index 0000000..a1ebe86
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb
@@ -0,0 +1,1404 @@
+#
+# tkextlib/tcllib/plotchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Simple plotting and charting package
+#
+# (The following is the original description of the library.)
+#
+# Plotchart is a Tcl-only package that focuses on the easy creation of
+# xy-plots, barcharts and other common types of graphical presentations.
+# The emphasis is on ease of use, rather than flexibility. The procedures
+# that create a plot use the entire canvas window, making the layout of the
+# plot completely automatic.
+#
+# This results in the creation of an xy-plot in, say, ten lines of code:
+# --------------------------------------------------------------------
+# package require Plotchart
+#
+# canvas .c -background white -width 400 -height 200
+# pack .c -fill both
+#
+# #
+# # Create the plot with its x- and y-axes
+# #
+# set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
+#
+# foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
+# $s plot series1 $x $y
+# }
+#
+# $s title "Data series"
+# --------------------------------------------------------------------
+#
+# A drawback of the package might be that it does not do any data management.
+# So if the canvas that holds the plot is to be resized, the whole plot must
+# be redrawn. The advantage, though, is that it offers a number of plot and
+# chart types:
+#
+# * XY-plots like the one shown above with any number of data series.
+# * Stripcharts, a kind of XY-plots where the horizontal axis is adjusted
+# automatically. The result is a kind of sliding window on the data
+# series.
+# * Polar plots, where the coordinates are polar instead of cartesian.
+# * Isometric plots, where the scale of the coordinates in the two
+# directions is always the same, i.e. a circle in world coordinates
+# appears as a circle on the screen.
+# You can zoom in and out, as well as pan with these plots (Note: this
+# works best if no axes are drawn, the zooming and panning routines do
+# not distinguish the axes), using the mouse buttons with the control
+# key and the arrow keys with the control key.
+# * Piecharts, with automatic scaling to indicate the proportions.
+# * Barcharts, with either vertical or horizontal bars, stacked bars or
+# bars side by side.
+# * Timecharts, where bars indicate a time period and milestones or other
+# important moments in time are represented by triangles.
+# * 3D plots (both for displaying surfaces and 3D bars)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Plotchart', '0.9')
+# TkPackage.require('Plotchart', '1.1')
+# TkPackage.require('Plotchart', '1.6.3')
+TkPackage.require('Plotchart')
+
+module Tk
+ module Tcllib
+ module Plotchart
+ PACKAGE_NAME = 'Plotchart'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Plotchart')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Plotchart
+ extend TkCore
+ ############################
+ def self.view_port(w, *args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', w.path, *(args.flatten))
+ end
+
+ def self.world_coordinates(w, *args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.world_3D_coordinates(w, *args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.coords_to_pixel(w, x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y))
+ end
+
+ def self.coords_3D_to_pixel(w, x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', w.path, x, y, z))
+ end
+
+ def self.plotconfig(*args)
+ case args.length
+ when 0, 1, 2
+ # 0: (no args) --> list of chat types
+ # 1: charttype --> list of components
+ # 2: charttype, component --> list of properties
+ simplelist(tk_call('::Plotchart::plotconfig', *args))
+ when 3
+ # 3: charttype, component, property --> current value
+ tk_call('::Plotchart::plotconfig', *args)
+ else
+ # 4: charttype, component, property, value : set new value
+ # 5+: Error on Tcl/Tk
+ tk_call('::Plotchart::plotconfig', *args)
+ nil
+ end
+ end
+
+ def self.plotpack(w, dir, *plots)
+ tk_call_without_enc('::Plotchart::plotpack', w.path, dir, *plots)
+ w
+ end
+
+ def self.polar_coordinates(w, radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', w.path, radmax)
+ end
+
+ def self.polar_to_pixel(w, rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', w.path, rad, phi))
+ end
+
+ def self.pixel_to_coords(w, x, y)
+ list(tk_call_without_enc('::Plotchart::pixelToCoords', w.path, x, y))
+ end
+
+ def self.determine_scale(*args) # (xmin, xmax, inverted=false)
+ tk_call_without_enc('::Plotchart::determineScale', *args)
+ end
+
+ def self.set_zoom_pan(w)
+ tk_call_without_enc('::Plotchart::setZoomPan', w.path)
+ end
+
+ ############################
+ module ChartMethod
+ include TkCore
+
+ def title(str)
+ tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str))
+ self
+ end
+
+ def save_plot(filename)
+ tk_call_without_enc(@chart, 'saveplot', filename)
+ self
+ end
+
+ def xtext(str)
+ tk_call_without_enc(@chart, 'xtext', _get_eval_enc_str(str))
+ self
+ end
+
+ def ytext(str)
+ tk_call_without_enc(@chart, 'ytext', _get_eval_enc_str(str))
+ self
+ end
+
+ def xconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'xconfig', "-#{key}",value)
+ end
+ self
+ end
+
+ def yconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'yconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def background(part, color_or_image, dir)
+ tk_call_without_enc(@chart, 'background',
+ part, color_or_image, dir)
+ self
+ end
+
+ def xticklines(color=None)
+ tk_call(@chart, 'xticklines', color)
+ self
+ end
+
+ def yticklines(color=None)
+ tk_call(@chart, 'yticklines', color)
+ self
+ end
+
+ def legendconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'legendconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'legendconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def legend(series, text)
+ tk_call_without_enc(@chart, 'legend',
+ _get_eval_enc_str(series), _get_eval_enc_str(text))
+ self
+ end
+
+ def balloon(*args) # args => (x, y, text, dir) or ([x, y], text, dir)
+ if args[0].kind_of?(Array)
+ # args => ([x, y], text, dir)
+ x, y = args.shift
+ else
+ # args => (x, y, text, dir)
+ x = args.shift
+ y = args.shift
+ end
+
+ text, dir = args
+
+ tk_call_without_enc(@chart, 'balloon', x, y,
+ _get_eval_enc_str(text), dir)
+ self
+ end
+
+ def balloonconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'balloonconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'balloonconfig', "-#{key}", value)
+ end
+ end
+
+ def plaintext(*args) # args => (x, y, text, dir) or ([x, y], text, dir)
+ if args[0].kind_of?(Array)
+ # args => ([x, y], text, dir)
+ x, y = args.shift
+ else
+ # args => (x, y, text, dir)
+ x = args.shift
+ y = args.shift
+ end
+
+ text, dir = args
+
+ tk_call_without_enc(@chart, 'plaintext', x, y,
+ _get_eval_enc_str(text), dir)
+ self
+ end
+
+ ############################
+
+ def view_port(*args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', @path, *(args.flatten))
+ self
+ end
+
+ def world_coordinates(*args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def world_3D_coordinates(*args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def coords_to_pixel(x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y))
+ end
+
+ def coords_3D_to_pixel(x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', @path, x, y, z))
+ end
+
+ def plotpack(dir, *plots)
+ tk_call_without_enc('::Plotchart::plotpack', @path, dir, *plots)
+ self
+ end
+
+ def polar_coordinates(radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', @path, radmax)
+ self
+ end
+
+ def polar_to_pixel(rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', @path, rad, phi))
+ end
+
+ def pixel_to_coords(x, y)
+ list(tk_call_without_enc('::Plotchart::pixelToCoords', @path, x, y))
+ end
+
+ def determine_scale(xmax, ymax)
+ tk_call_without_enc('::Plotchart::determineScale', @path, xmax, ymax)
+ self
+ end
+
+ def set_zoom_pan()
+ tk_call_without_enc('::Plotchart::setZoomPan', @path)
+ self
+ end
+ end
+
+ ############################
+ class XYPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXYPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, x, y)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series), x, y)
+ self
+ end
+
+ def contourlines(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourlines', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def contourfill(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourfill', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def contourbox(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourbox', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def color_map(colors)
+ colors = array2tk_list(colors) if colors.kind_of?(Array)
+
+ tk_call_without_enc(@chart, 'colorMap', colors)
+ self
+ end
+
+ def grid_cells(xcrd, ycrd)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+
+ tk_call_without_enc(@chart, 'grid', xcrd, ycrd)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dataconfig', series, "-#{key}", value)
+ end
+ end
+
+ def rescale(xscale, yscale) # xscale|yscale => [newmin, newmax, newstep]
+ tk_call_without_enc(@chart, 'rescale', xscale, yscale)
+ self
+ end
+
+ def trend(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'trend',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+
+ def rchart(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'rchart',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+
+ def interval(series, xcrd, ymin, ymax, ycenter=None)
+ tk_call(@chart, 'interval', series, xcrd, ymin, ymax, ycenter)
+ self
+ end
+
+ def box_and_whiskers(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'box-and-whiskers',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+ alias box_whiskers box_and_whiskers
+
+ def vectorconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'vectorconfig',
+ _get_eval_enc_str(series), *hash_kv(key, true))
+ else
+ tk_call(@chart, 'vectorconfig', series, "-#{key}", value)
+ end
+ self
+ end
+
+ def vector(series, xcrd, ycrd, ucmp, vcmp)
+ tk_call_without_enc(@chart, 'vector', _get_eval_enc_str(series),
+ xcrd, ycrd, ucmp, vcmp)
+ self
+ end
+
+ def dotconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dotconfig',
+ _get_eval_enc_str(series), *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dotconfig', series, "-#{key}", value)
+ end
+ self
+ end
+
+ def dot(series, xcrd, ycrd, value)
+ tk_call_without_enc(@chart, 'dot', _get_eval_enc_str(series),
+ xcrd, ycrd, value)
+ self
+ end
+ end
+
+ ############################
+ class Stripchart < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createStripchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class TXPlot < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTXPlot'.freeze
+ ].freeze
+ end
+
+ ############################
+ class XLogYPlot < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXLogYPlot'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Histogram < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHistogram'.freeze
+ ].freeze
+ end
+
+ ############################
+ class PolarPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPolarplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] radius_data [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @radius_data = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @radius_data = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@radius_data))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, radius, angle)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series),
+ radius, angle)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', _get_eval_enc_str(series),
+ *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dataconfig', series, "-#{key}", value)
+ end
+ end
+ end
+ Polarplot = PolarPlot
+
+ ############################
+ class IsometricPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createIsometricPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, [, step] [, keys])
+ # xaxis := Array of [minimum, maximum]
+ # yaxis := Array of [minimum, maximum]
+ # step := Float of stepsize | "noaxes" | :noaxes
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis),
+ @stepsize)
+ end
+ private :_create_chart
+
+ def plot(type, *args)
+ self.__send__("plot_#{type.to_s.tr('-', '_')}", *args)
+ end
+
+ def plot_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'filled-rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'circle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'filled-circle', *(args.flatten))
+ self
+ end
+ end
+ Isometricplot = IsometricPlot
+
+ ############################
+ class Plot3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, zaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def plot_function(cmd=Proc.new)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfunc', "#{@path}_#{@chart}")
+ self
+ end
+
+ def plot_funcont(conts, cmd=Proc.new)
+ conts = array2tk_list(conts) if conts.kind_of?(Array)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfuncont', "#{@path}_#{@chart}", conts)
+ self
+ end
+
+ def grid_size(nxcells, nycells)
+ tk_call_without_enc(@chart, 'gridsize', nxcells, nycells)
+ self
+ end
+
+ def plot_line(dat, color)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotline', dat, color)
+ self
+ end
+
+ def plot_data(dat)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotdata', dat)
+ self
+ end
+
+ def zconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'zconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'zconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def colour(fill, border)
+ # configure the colours to use for polygon borders and inner area
+ tk_call_without_enc(@chart, 'colour', fill, border)
+ self
+ end
+ alias colours colour
+ alias colors colour
+ alias color colour
+ end
+
+ ############################
+ class Barchart3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DBarchart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] yaxis, nobars [, keys])
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # nobars := number of bars
+ if args[0].kind_of?(Array)
+ @yaxis = args.shift
+ @nobars = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @yaxis = args.shift
+ @nobars = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@yaxis), @nobars)
+ end
+ private :_create_chart
+
+ def plot(label, yvalue, color)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(label),
+ _get_eval_enc_str(yvalue), color)
+ self
+ end
+
+ def config(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'config', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'config', "-#{key}", value)
+ end
+ self
+ end
+ end
+
+ ############################
+ class RibbonChart3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DRibbonChart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] names, yaxis, zaxis [, keys])
+ # names := Array of the series
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @names = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @names = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@names),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def line(*args) # xypairs, color
+ color = args.pop # last argument is a color
+ xypairs = TkComm.slice_ary(args.flatten, 2) # regenerate xypairs
+ tk_call_without_enc(@chart, 'line', xypairs, color)
+ self
+ end
+
+ def area(*args) # xypairs, color
+ color = args.pop # last argument is a color
+ xypairs = TkComm.slice_ary(args.flatten, 2) # regenerate xypairs
+ tk_call_without_enc(@chart, 'area', xypairs, color)
+ self
+ end
+
+ def zconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'zconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'zconfig',"-#{key}", value)
+ end
+ self
+ end
+ end
+
+
+ ############################
+ class Piechart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPiechart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent] [, keys])
+ if args[0].kind_of?(Tk::Canvas)
+ parent = args.shift
+ @path = parent.path
+ else
+ super(*args) # create canvas widget
+ end
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path)
+ end
+ private :_create_chart
+
+ def plot(*dat) # argument is a list of [label, value]
+ tk_call(@chart, 'plot', dat.flatten)
+ self
+ end
+
+ def colours(*list)
+ tk_call_without_enc(@chart, 'colours', *list)
+ self
+ end
+ alias colors colours
+ end
+
+
+ ############################
+ class Radialchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createRadialchart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] names, scale, style [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @names = args.shift
+ @scale = args.shift
+ @style = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @names = args.shift
+ @scale = args.shift
+ @style = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@names), @scale, @style)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(data, color, thickness)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(data),
+ color, thickness)
+ self
+ end
+
+ def colours(*list)
+ tk_call_without_enc(@chart, 'colours', *list)
+ self
+ end
+ alias colors colours
+ end
+
+ ############################
+ class Barchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBarchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] xlabels, ylabels [, series] [, keys])
+ # xlabels, ylabels := labels | axis ( depend on normal or horizontal )
+ # labels := Array of [label, label, ...]
+ # (It determines the number of bars that will be plotted per series.)
+ # axis := Array of [minimum, maximum, stepsize]
+ # series := Integer number of data series | 'stacked' | :stacked
+ if args[0].kind_of?(Array)
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xlabels), array2tk_list(@ylabels),
+ @series_size)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, dat, col=None)
+ tk_call(@chart, 'plot', series, dat, col)
+ self
+ end
+
+ def colours(*cols)
+ # set the colours to be used
+ tk_call(@chart, 'colours', *cols)
+ self
+ end
+ alias colour colours
+ alias colors colours
+ alias color colours
+ end
+
+ ############################
+ class HorizontalBarchart < Barchart
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHorizontalBarchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Boxplot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBoxplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, ylabels [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := List of labels for the y-axis
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @ylabels = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @ylabels = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@ylabels))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(label, *values)
+ tk_call(@chart, 'plot', label, values.flatten)
+ self
+ end
+ end
+
+ ############################
+ class RightAxis < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createRightAxis'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] yaxis [, keys])
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @yaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+ end
+
+ ############################
+ class Timechart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTimechart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # items := Expected/maximum number of items
+ # ( This determines the vertical spacing. )
+ if args[0].kind_of?(String)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, @items)
+ end
+ private :_create_chart
+
+ def period(txt, time_begin, time_end, col=None)
+ tk_call(@chart, 'period', txt, time_begin, time_end, col)
+ self
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call(@chart, 'vertline', txt, time)
+ self
+ end
+
+ def hscroll=(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ scr
+ end
+ def hscroll(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ self
+ end
+
+ def vscroll=(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ scr
+ end
+ def vscroll(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ self
+ end
+ end
+
+ ############################
+ class Ganttchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createGanttchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, text_width] [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # args := Expected/maximum number of items
+ # ( This determines the vertical spacing. ),
+ # Expected/maximum width of items,
+ # Option Hash ( { key=>value, ... } )
+ if args[0].kind_of?(String)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @args = args
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @args = args
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, *args)
+ end
+ private :_create_chart
+
+ def task(txt, time_begin, time_end, completed=0.0)
+ list(tk_call(@chart, 'task', txt, time_begin, time_end,
+ completed)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call(@chart, 'vertline', txt, time)
+ self
+ end
+
+ def connect(from_task, to_task)
+ from_task = array2tk_list(from_task) if from_task.kind_of?(Array)
+ to_task = array2tk_list(to_task) if to_task.kind_of?(Array)
+
+ tk_call(@chart, 'connect', from_task, to_task)
+ self
+ end
+
+ def summary(txt, tasks)
+ tasks = array2tk_list(tasks) if tasks.kind_of?(Array)
+ tk_call(@chart, 'summary', tasks)
+ self
+ end
+
+ def color_of_part(keyword, newcolor)
+ tk_call(@chart, 'color', keyword, newcolor)
+ self
+ end
+
+ def font_of_part(keyword, newfont)
+ tk_call(@chart, 'font', keyword, newfont)
+ self
+ end
+
+ def hscroll=(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ scr
+ end
+ def hscroll(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ self
+ end
+
+ def vscroll=(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ scr
+ end
+ def vscroll(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ self
+ end
+ end
+
+ ############################
+ class PlotSeries < TkObject
+ SeriesID_TBL = TkCore::INTERP.create_table
+
+ (Series_ID = ['series'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TkCore::INTERP.init_ip_env{
+ SeriesID_TBL.mutex.synchronize{ SeriesID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ path = chart.path
+ SeriesID_TBL.mutex.synchronize{
+ if SeriesID_TBL[path]
+ SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(chart, keys=nil)
+ @parent = @chart_obj = chart
+ @ppath = @chart_obj.path
+ Series_ID.mutex.synchronize{
+ @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
+ Series_ID[1].succ!
+ }
+ SeriesID_TBL.mutex.synchronize{
+ SeriesID_TBL[@ppath] ||= {}
+ SeriesID_TBL[@ppath][@id] = self
+ }
+ dataconfig(keys) if keys.kind_of?(Hash)
+ end
+
+ def plot(*args)
+ @chart_obj.plot(@series, *args)
+ end
+
+ def dataconfig(key, value=None)
+ @chart_obj.dataconfig(@series, key, value)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb
new file mode 100644
index 0000000..d22dafa
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb
@@ -0,0 +1,65 @@
+#
+# tkextlib/tcllib/ruler.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * ruler widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::ruler', '1.0')
+TkPackage.require('widget::ruler')
+
+module Tk::Tcllib
+ module Widget
+ class Ruler < TkWindow
+ PACKAGE_NAME = 'widget::ruler'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::ruler')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Ruler
+ TkCommandNames = ['::widget::ruler'.freeze].freeze
+
+ def __boolval_optkeys
+ ['showvalues', 'outline', 'grid']
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ ['interval', 'sizes']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def redraw
+ tk_send('redraw')
+ self
+ end
+
+ def shade(org, dest, frac)
+ tk_send('shade', org, dest, frac)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb
new file mode 100644
index 0000000..75fa36b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/tcllib/screenruler.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * screenruler dialog
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::screenruler', '1.1')
+TkPackage.require('widget::screenruler')
+
+module Tk::Tcllib
+ module Widget
+ class ScreenRuler < TkWindow
+ PACKAGE_NAME = 'widget::ruler'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::screenruler')
+ rescue
+ ''
+ end
+ end
+ end
+ Screenruler = ScreenRuler
+ end
+end
+
+class Tk::Tcllib::Widget::ScreenRuler
+ TkCommandNames = ['::widget::screenruler'.freeze].freeze
+
+ def __boolval_optkeys
+ ['topmost', 'reflect']
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ ['alpha']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def display
+ tk_send('display')
+ self
+ end
+ alias show display
+
+ def hide
+ tk_send('hide')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb
new file mode 100644
index 0000000..c9488b4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb
@@ -0,0 +1,57 @@
+#
+# tkextlib/tcllib/scrolledwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * scrolledwindow widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::scrolledwindow', '1.2')
+TkPackage.require('widget::scrolledwindow')
+
+module Tk::Tcllib
+ module Widget
+ class Scrolledwindow < Tk::Tile::TFrame
+ PACKAGE_NAME = 'widget::scrolledwindow'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::scrolledwindow')
+ rescue
+ ''
+ end
+ end
+ end
+ ScrolledWindow = Scrolledwindow
+ end
+end
+
+class Tk::Tcllib::Widget::ScrolledWindow
+ TkCommandNames = ['::widget::scrolledwindow'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send_without_enc('getframe'))
+ end
+ alias get_frame getframe
+
+ def setwidget(w)
+ window(tk_send_without_enc('setwidget', w))
+ end
+ alias set_widget setwidget
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb
new file mode 100644
index 0000000..c9f6062
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/tcllib/scrollwin.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Scrolled widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::scrolledwindow', '1.0')
+TkPackage.require('widget::scrolledwindow')
+
+module Tk::Tcllib
+ module Widget
+ class ScrolledWindow < TkWindow
+ PACKAGE_NAME = 'widget::scrolledwindow'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::scrolledwindow')
+ rescue
+ ''
+ end
+ end
+ end
+ Scrolledwindow = ScrolledWindow
+ end
+end
+
+class Tk::Tcllib::Widget::ScrolledWindow
+ TkCommandNames = ['::widget::scrolledwindow'.freeze].freeze
+
+ def __numlistval_optkeys
+ ['ipad']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def get_frame
+ window(tk_send('getframe'))
+ end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
new file mode 100644
index 0000000..46a4b9d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
@@ -0,0 +1,79 @@
+#
+# tkextlib/tcllib/statusbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * statusbar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::statusbar', '1.2')
+TkPackage.require('widget::statusbar')
+
+module Tk::Tcllib
+ module Widget
+ class Statusbar < Tk::Tile::TFrame
+ PACKAGE_NAME = 'widget::statusbar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::statusbar')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Statusbar
+ TkCommandNames = ['::widget::statusbar'.freeze].freeze
+
+ def __boolval_optkeys
+ super() << 'separator' << 'resize' << 'resizeseparator'
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send_without_enc('getframe'))
+ end
+ alias get_frame getframe
+
+ def add(w, keys={})
+ window(tk_send_without_enc('setwidget', *(hash_kv(keys))))
+ end
+
+ def remove(*wins)
+ tk_send_without_enc('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send_without_enc('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins)
+ tk_send_without_enc('delete', *wins)
+ self
+ end
+
+ def items(pat=None)
+ tk_split_list(tk_send('items', pat))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb
new file mode 100644
index 0000000..dac6916
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/tcllib/style.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * select and use some 'style' of option (resource) DB
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk::Tcllib
+ module Style
+ PACKAGE_NAME = 'style'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('style')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/style' extension is not available on your current environment."
+ end
+
+ def self.names
+ Tk::Tcllib::Style.not_available
+ end
+
+ def self.use(style)
+ Tk::Tcllib::Style.not_available
+ end
+ end
+end
+
+# TkPackage.require('style', '0.1')
+# TkPackage.require('style', '0.3')
+TkPackage.require('style')
+
+module Tk::Tcllib
+ class << Style
+ undef not_available
+ end
+
+ module Style
+ extend TkCore
+
+ def self.names
+ tk_split_simplelist(tk_call('style::names'))
+ end
+
+ def self.use(style)
+ tk_call('style::use', style)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb
new file mode 100644
index 0000000..adc9c4a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb
@@ -0,0 +1,51 @@
+#
+# tkextlib/tcllib/superframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Superframe widget - enhanced labelframe widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::superframe', '1.0')
+TkPackage.require('widget::superframe')
+
+module Tk::Tcllib
+ module Widget
+ class SuperFrame < TkWindow
+ PACKAGE_NAME = 'widget::superframe'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::superframe')
+ rescue
+ ''
+ end
+ end
+ end
+ Superframe = SuperlFrame
+ end
+end
+
+class Tk::Tcllib::Widget::SuperFrame
+ TkCommandNames = ['::widget::superframe'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def labelwidget
+ window(tk_send('labelwidget'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb
new file mode 100644
index 0000000..7698640
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb
@@ -0,0 +1,150 @@
+#
+# tkextlib/tcllib/swaplist.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A dialog which allows a user to move options between two lists
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('swaplist', '0.1')
+TkPackage.require('swaplist')
+
+module Tk::Tcllib
+ class Swaplist_Dialog < TkWindow
+ PACKAGE_NAME = 'swaplist'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('swaplist')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+
+class Tk::Tcllib::Swaplist_Dialog
+ TkCommandNames = ['::swaplist::swaplist'.freeze].freeze
+ WidgetClassName = 'Swaplist'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def initialize(*args)
+ # args = (parent=nil, complete_list=[], selected_list=[], keys=nil)
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ @selected_list = args.pop
+ @complete_list = args.pop
+ @keys = _symbolkey2str(keys)
+ args.push(keys)
+ else
+ @selected_list = keys
+ @complete_list = args.pop
+ @keys = {}
+ end
+
+ @selected_list = [] unless @selected_list
+ @complete_list = [] unless @complete_list
+
+ @variable = TkVariable.new
+ @status = nil
+
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ @variable.value = ''
+ @status = bool(tk_call(self.class::TkCommandNames[0],
+ @path, @variable,
+ @complete_list, @selected_list,
+ *hash_kv(@keys)))
+ end
+ alias display show
+
+ def status
+ @status
+ end
+
+ def value
+ @variable.list
+ end
+ alias selected value
+
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'complete_list'
+ @complete_list
+ elsif slot == 'selected_list'
+ @selected_list
+ else
+ @keys[slot]
+ end
+ end
+ def cget(slot)
+ cget_strict(slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ if slot == 'complete_list'
+ @complete_list = value
+ elsif slot == 'selected_list'
+ @selected_list = value
+ else
+ @keys[slot] = value
+ end
+ else
+ if slot == 'complete_list'
+ @complete_list = []
+ elsif slot == 'selected_list'
+ @selected_list = []
+ else
+ @keys.delete(slot)
+ end
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ if slot == 'complete_list'
+ [ slot, nil, nil, nil, @complete_list ]
+ elsif slot == 'selected_list'
+ [ slot, nil, nil, nil, @selected_list ]
+ else
+ [ slot, nil, nil, nil, @keys[slot] ]
+ end
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
+ << [ 'complete_list', nil, nil, nil, @complete_list ] \
+ << [ 'selected_list', nil, nil, nil, @selected_list ]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb
new file mode 100644
index 0000000..bf5ab66
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb
@@ -0,0 +1,28 @@
+#
+# tkextlib/tcllib/tablelist.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A multi-column listbox
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# check Tile extension :: If already loaded, use tablelist_tile.
+unless defined? Tk::Tcllib::Tablelist_usingTile
+ Tk::Tcllib::Tablelist_usingTile =
+ TkPackage.provide('tile') || TkPackage.provide('Ttk')
+end
+
+if Tk::Tcllib::Tablelist_usingTile
+ # with Tile
+ require 'tkextlib/tcllib/tablelist_tile'
+
+else
+ # without Tile
+
+ # TkPackage.require('tablelist', '4.2')
+ TkPackage.require('tablelist')
+
+ require 'tkextlib/tcllib/tablelist_core'
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
new file mode 100644
index 0000000..2a5c415
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
@@ -0,0 +1,1072 @@
+#
+# tkextlib/tcllib/tablelist_core.rb
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * This file is required by 'tkextlib/tcllib/tablelist.rb' or
+# 'tkextlib/tcllib/tablelist_tile.rb'.
+#
+
+module Tk
+ module Tcllib
+ class Tablelist < TkWindow
+ if Tk::Tcllib::Tablelist_usingTile
+ PACKAGE_NAME = 'Tablelist_tile'.freeze
+ else
+ PACKAGE_NAME = 'Tablelist'.freeze
+ end
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require(self.package_name)
+ rescue
+ ''
+ end
+ end
+
+ def self.use_Tile?
+ (Tk::Tcllib::Tablelist_usingTile)? true: false
+ end
+ end
+ TableList = Tablelist
+ end
+end
+
+module Tk::Tcllib::TablelistItemConfig
+ include TkItemConfigMethod
+
+ def _to_idx(idx)
+ if idx.kind_of?(Array)
+ idx.collect{|elem| _get_eval_string(elem)}.join(',')
+ else
+ idx
+ end
+ end
+ def _from_idx(idx)
+ return idx unless idx.kind_of?(String)
+
+ if idx[0] == ?@ # '@x,y'
+ idx
+ elsif idx =~ /([^,]+),([^,]+)/
+ row = $1, column = $2
+ [num_or_str(row), num_or_str(column)]
+ else
+ num_or_str(idx)
+ end
+ end
+ private :_to_idx, :_from_idx
+
+ def __item_cget_cmd(mixed_id)
+ [self.path, mixed_id[0] + 'cget', _to_idx(mixed_id[1])]
+ end
+ def __item_config_cmd(mixed_id)
+ [self.path, mixed_id[0] + 'configure', _to_idx(mixed_id[1])]
+ end
+
+ def cell_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['cell', tagOrId], option)
+ end
+ def cell_cget(tagOrId, option)
+ itemcget(['cell', tagOrId], option)
+ end
+ def cell_cget_strict(tagOrId, option)
+ itemcget_strict(['cell', tagOrId], option)
+ end
+ def cell_configure(tagOrId, slot, value=None)
+ itemconfigure(['cell', tagOrId], slot, value)
+ end
+ def cell_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['cell', tagOrId], slot)
+ end
+ def current_cell_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['cell', tagOrId], slot)
+ end
+ alias cellcget_tkstring cell_cget_tkstring
+ alias cellcget cell_cget
+ alias cellcget_strict cell_cget_strict
+ alias cellconfigure cell_configure
+ alias cellconfiginfo cell_configinfo
+ alias current_cellconfiginfo current_cell_configinfo
+
+ def column_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['column', tagOrId], option)
+ end
+ def column_cget(tagOrId, option)
+ itemcget(['column', tagOrId], option)
+ end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
+ def column_configure(tagOrId, slot, value=None)
+ itemconfigure(['column', tagOrId], slot, value)
+ end
+ def column_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['column', tagOrId], slot)
+ end
+ def current_column_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['column', tagOrId], slot)
+ end
+ alias columncget_tkstring column_cget_tkstring
+ alias columncget column_cget
+ alias columncget_strict column_cget_strict
+ alias columnconfigure column_configure
+ alias columnconfiginfo column_configinfo
+ alias current_columnconfiginfo current_column_configinfo
+
+ def row_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['row', tagOrId], option)
+ end
+ def row_cget(tagOrId, option)
+ itemcget(['row', tagOrId], option)
+ end
+ def row_cget_strict(tagOrId, option)
+ itemcget_strict(['row', tagOrId], option)
+ end
+ def row_configure(tagOrId, slot, value=None)
+ itemconfigure(['row', tagOrId], slot, value)
+ end
+ def row_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['row', tagOrId], slot)
+ end
+ def current_row_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['row', tagOrId], slot)
+ end
+ alias rowcget_tkstring row_cget_tkstring
+ alias rowcget row_cget
+ alias rowcget_strict row_cget_strict
+ alias rowconfigure row_configure
+ alias rowconfiginfo row_configinfo
+ alias current_rowconfiginfo current_row_configinfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::Tcllib::Tablelist
+ include Tk::Tcllib::TablelistItemConfig
+ include Scrollable
+
+ TkCommandNames = ['::tablelist::tablelist'.freeze].freeze
+ WidgetClassName = 'Tablelist'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ ##########################
+
+ def __numval_optkeys
+ super() + ['titlecolumns']
+ end
+ private :__numval_optkeys
+
+ def __strval_optkeys
+ super() + ['snipstring']
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() - ['takefocus'] + [
+ 'forceeditendcommand', 'movablecolumns', 'movablerows',
+ 'protecttitlecolumns', 'resizablecolumns', 'setfocus',
+ 'showarrow', 'showlabels', 'showseparators'
+ ]
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() + ['columns', 'columntitles']
+ end
+ private :__listval_optkeys
+
+ def __tkvariable_optkeys
+ super() + ['listvariable']
+ end
+ private :__tkvariable_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ super().update('stretch'=>proc{|v|
+ (v == 'all')? v: simplelist(v)
+ },
+ 'takefocus'=>proc{|v|
+ case v
+ when '1'
+ true
+ when '0'
+ false
+ when ''
+ nil
+ else # cmd
+ tk_tcl2ruby(cmd)
+ end
+ })
+ end
+ private :__val2ruby_optkeys
+
+ def __ruby2val_optkeys # { key=>proc, ... }
+ # The method is used to convert a ruby's object to a opt-value.
+ # When set the value of the option "key", "proc.call(value)" is called.
+ # That is, "-#{key} #{proc.call(value)}".
+ super().update('stretch'=>proc{|v|
+ (v.kind_of?(Array))? v.collect{|e| _to_idx(e)}: v
+ },
+ 'takefocus'=>proc{|v|
+ case v
+ when true
+ '1'
+ when false
+ '0'
+ when nil
+ ''
+ else
+ _get_eval_string(v)
+ end
+ })
+ end
+ private :__ruby2val_optkeys
+
+ def __font_optkeys
+ super() + ['labelfont']
+ end
+ private :__font_optkeys
+
+ ##########################
+
+ def __item_strval_optkeys(id)
+ if id[0] == 'cell'
+ super(id) + ['title']
+ else
+ super(id) - ['text'] + ['title', 'name']
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_boolval_optkeys(id)
+ super(id) + [
+ 'changesnipside', 'editable', 'hide', 'resizable', 'selectable',
+ 'showarrow', 'showlinenumbers', 'stretchable', 'stretchwindow', 'wrap'
+ ]
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ if id[0] == 'cell'
+ super(id)
+ else
+ super(id) + ['text']
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_font_optkeys(id)
+ # maybe need to override
+ super(id) + ['labelfont']
+ end
+ private :__item_font_optkeys
+
+ ##########################
+
+ def activate(index)
+ tk_send('activate', _to_idx(index))
+ self
+ end
+
+ def activate_cell(index)
+ tk_send('activatecell', _to_idx(index))
+ self
+ end
+ alias activatecell activate_cell
+
+ def get_attrib(name=nil)
+ if name && name != None
+ tk_send('attrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('attrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_attrib(*args)
+ tk_send('attrib', *(args.flatten))
+ self
+ end
+
+ def bbox(index)
+ list(tk_send('bbox', _to_idx(index)))
+ end
+
+ def bodypath
+ window(tk_send('bodypath'))
+ end
+
+ def bodytag
+ TkBindTag.new_by_name(tk_send('bodytag'))
+ end
+
+ def cancel_editing
+ tk_send('cancelediting')
+ self
+ end
+ alias cancelediting cancel_editing
+
+ def get_cellattrib(name=nil)
+ if name && name != None
+ tk_send('cellattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('cellattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_cellattrib(*args)
+ tk_send('cellattrib', *(args.flatten))
+ self
+ end
+
+ def cellindex(idx)
+ _from_idx(tk_send('cellindex', _to_idx(idx)))
+ end
+
+ def cellselection_anchor(idx)
+ tk_send('cellselection', 'anchor', _to_idx(idx))
+ self
+ end
+
+ def cellselection_clear(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('cellselection', 'clear', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('cellselection', 'clear', first, last)
+ end
+ self
+ end
+
+ def cellselection_includes(idx)
+ bool(tk_send('cellselection', 'includes', _to_idx(idx)))
+ end
+
+ def cellselection_set(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('cellselection', 'set', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('cellselection', 'set', first, last)
+ end
+ self
+ end
+
+ def get_columnattrib(name=nil)
+ if name && name != None
+ tk_send('columnattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('columnattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_columnattrib(*args)
+ tk_send('columnattrib', *(args.flatten))
+ self
+ end
+
+ def columncount
+ number(tk_send('columncount'))
+ end
+
+ def columnindex(idx)
+ number(tk_send('columnindex', _to_idx(idx)))
+ end
+
+ def columnwidth(idx, opt=nil)
+ if opt
+ number(tk_send('columnwidth', _to_idx(idx), "-#{opt}"))
+ else
+ number(tk_send('columnwidth', _to_idx(idx)))
+ end
+ end
+ def requested_columnwidth(idx)
+ columnwidth(idx, 'requested')
+ end
+ def stretched_columnwidth(idx)
+ columnwidth(idx, 'stretched')
+ end
+ def total_columnwidth(idx)
+ columnwidth(idx, 'total')
+ end
+
+ def configcelllist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcelllist', ary)
+ self
+ end
+ alias config_celllist configcelllist
+
+ def configcells(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcells', *ary)
+ self
+ end
+ alias config_cells configcells
+
+ def configcolumnlist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcolumnlist', ary)
+ self
+ end
+ alias config_columnlist configcolumnlist
+
+ def configcolumns(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcolumns', *ary)
+ self
+ end
+ alias config_columns configcolumns
+
+ def configrowlist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configrowlist', ary)
+ self
+ end
+ alias config_rowlist configrowlist
+
+ def configrows(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configrows', *ary)
+ self
+ end
+ alias config_rows configrows
+
+ def containing(y)
+ idx = num_or_str(tk_send('containing', y))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+
+ def containing_cell(x, y)
+ idx = _from_idx(tk_send('containingcell', x, y))
+ if idx.kind_of?(Array)
+ [
+ ((idx[0].kind_of?(Fixnum) && idx[0] < 0)? nil: idx[0]),
+ ((idx[1].kind_of?(Fixnum) && idx[1] < 0)? nil: idx[1])
+ ]
+ else
+ idx
+ end
+ end
+ alias containingcell containing_cell
+
+ def containing_column(x)
+ idx = num_or_str(tk_send('containingcolumn', x))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+ alias containingcolumn containing_column
+
+ def curcellselection
+ simplelist(tk_send('curcellselection')).collect!{|idx| _from_idx(idx)}
+ end
+
+ def curselection
+ list(tk_send('curselection'))
+ end
+
+ def delete_items(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('delete', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('delete', first, last)
+ end
+ self
+ end
+ alias delete delete_items
+ alias deleteitems delete_items
+
+ def delete_columns(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('deletecolumns', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('deletecolumns', first, last)
+ end
+ self
+ end
+ alias deletecolumns delete_columns
+
+ def edit_cell(idx)
+ tk_send('editcell', _to_idx(idx))
+ self
+ end
+ alias editcell edit_cell
+
+ def editwintag
+ TkBindTag.new_by_name(tk_send('editwintag'))
+ end
+
+ def editwinpath
+ window(tk_send('editwinpath'))
+ end
+
+ def entrypath
+ window(tk_send('entrypath'))
+ end
+
+ def fill_column(idx, txt)
+ tk_send('fillcolumn', _to_idx(idx), txt)
+ self
+ end
+ alias fillcolumn fill_column
+
+ def finish_editing
+ tk_send('finishediting')
+ self
+ end
+ alias finishediting finish_editing
+
+ def formatinfo
+ key, row, col = simplelist(tk_send('formatinfo'))
+ [key, number(row), number(col)]
+ end
+
+ def get(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('get', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('get', first, last))
+ end
+ end
+
+ def get_cells(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getcells', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getcells', first, last))
+ end
+ end
+ alias getcells get_cells
+
+ def get_columns(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getcolumns', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getcolumns', first, last))
+ end
+ end
+ alias getcolumns get_columns
+
+ def get_keys(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getkeys', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getkeys', first, last))
+ end
+ end
+ alias getkeys get_keys
+
+ def has_attrib?(name)
+ bool(tk_send('hasattrib', name))
+ end
+
+ def has_cellattrib?(idx, name)
+ bool(tk_send('hascellattrib', _to_idx(idx), name))
+ end
+
+ def has_columnattrib?(idx, name)
+ bool(tk_send('hascolumnattrib', _to_idx(idx), name))
+ end
+
+ def has_rowattrib?(idx, name)
+ bool(tk_send('hasrowattrib', _to_idx(idx), name))
+ end
+
+ def imagelabelpath(idx)
+ window(tk_send('imagelabelpath', _to_idx(idx)))
+ end
+
+ def index(idx)
+ number(tk_send('index', _to_idx(idx)))
+ end
+
+ def insert(idx, *items)
+ tk_send('insert', _to_idx(idx), *items)
+ self
+ end
+
+ def insert_columnlist(idx, columnlist)
+ tk_send('insertcolumnlist', _to_idx(idx), columnlist)
+ self
+ end
+ alias insertcolumnlist insert_columnlist
+
+ def insert_columns(idx, *args)
+ tk_send('insertcolums', _to_idx(idx), *args)
+ self
+ end
+ alias insertcolumns insert_columns
+
+ def insert_list(idx, list)
+ tk_send('insertlist', _to_idx(idx), list)
+ self
+ end
+ alias insertlist insert_list
+
+ def is_elem_snipped?(cellidx, tkvar)
+ bool(tk_send('iselemsnipped', _to_idx(cellidx), tkvar))
+ end
+ alias elem_snipped? is_elem_snipped?
+
+ def is_title_snipped?(colidx, tkvar)
+ bool(tk_send('istitlesnipped', _to_idx(colidx), tkvar))
+ end
+ alias title_snipped? is_title_snipped?
+
+ def itemlistvar
+ TkVarAccess.new(tk_send('itemlistvar'))
+ end
+
+ def labelpath(idx)
+ window(tk_send('labelpath', _to_idx(idx)))
+ end
+
+ def labels
+ simplelist(tk_send('labels'))
+ end
+
+ def labeltag
+ TkBindTag.new_by_name(tk_send('labeltag'))
+ end
+
+ def move(src, target)
+ tk_send('move', _to_idx(src), _to_idx(target))
+ self
+ end
+
+ def move_column(src, target)
+ tk_send('movecolumn', _to_idx(src), _to_idx(target))
+ self
+ end
+ alias movecolumn move_column
+
+ def nearest(y)
+ _from_idx(tk_send('nearest', y))
+ end
+
+ def nearest_cell(x, y)
+ _from_idx(tk_send('nearestcell', x, y))
+ end
+ alias nearestcell nearest_cell
+
+ def nearest_column(x)
+ _from_idx(tk_send('nearestcolumn', x))
+ end
+ alias nearestcolumn nearest_column
+
+ def reject_input
+ tk_send('rejectinput')
+ self
+ end
+ alias rejectinput reject_input
+
+ def reset_sortinfo
+ tk_send('resetsortinfo')
+ self
+ end
+ alias resetsortinfo reset_sortinfo
+
+ def get_rowattrib(name=nil)
+ if name && name != None
+ tk_send('rowattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('rowattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_rowattrib(*args)
+ tk_send('rowattrib', *(args.flatten))
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send('scan', 'mark', x, y)
+ self
+ end
+
+ def scan_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(idx)
+ tk_send('see', _to_idx(idx))
+ self
+ end
+
+ def see_cell(idx)
+ tk_send('seecell', _to_idx(idx))
+ self
+ end
+ alias seecell see_cell
+
+ def see_column(idx)
+ tk_send('seecolumn', _to_idx(idx))
+ self
+ end
+ alias seecolumn see_column
+
+ def selection_anchor(idx)
+ tk_send('selection', 'anchor', _to_idx(idx))
+ self
+ end
+
+ def selection_clear(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('selection', 'clear', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('selection', 'clear', first, last)
+ end
+ self
+ end
+
+ def selection_includes(idx)
+ bool(tk_send('selection', 'includes', _to_idx(idx)))
+ end
+
+ def selection_set(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('selection', 'set', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('selection', 'set', first, last)
+ end
+ self
+ end
+
+ def separatorpath(idx=nil)
+ if idx
+ window(tk_send('separatorpath', _to_idx(idx)))
+ else
+ window(tk_send('separatorpath'))
+ end
+ end
+
+ def separators
+ simplelist(tk_send('separators')).collect!{|w| window(w)}
+ end
+
+ def size
+ number(tk_send('size'))
+ end
+
+ def sort(order=nil)
+ if order
+ order = order.to_s
+ order = '-' << order if order[0] != ?-
+ if order.length < 2
+ order = nil
+ end
+ end
+ if order
+ tk_send('sort', order)
+ else
+ tk_send('sort')
+ end
+ self
+ end
+ def sort_increasing
+ tk_send('sort', '-increasing')
+ self
+ end
+ def sort_decreasing
+ tk_send('sort', '-decreasing')
+ self
+ end
+
+
+ # default of 'labelcommand' option
+ DEFAULT_labelcommand_value =
+ DEFAULT_sortByColumn_cmd = '::tablelist::sortByColumn'
+
+ # default of 'labelcommand2' option
+ DEFAULT_labelcommand2_value =
+ DEFAULT_addToSortColumns_cmd = '::tablelist::addToSortColumns'
+
+ def sortByColumn_with_event_generate(idx)
+ tk_call('::tablelist::sortByColumn', @path, _to_idx(idx))
+ end
+
+ def addToSortColumns_with_event_generate(idx)
+ tk_call('::tablelist::addToSortColumns', @path, _to_idx(idx))
+ end
+
+ def sort_by_column(idx, order=nil)
+ if order
+ order = order.to_s
+ order = '-' << order if order[0] != ?-
+ if order.length < 2
+ order = nil
+ end
+ end
+ if order
+ tk_send('sortbycolumn', _to_idx(idx), order)
+ else
+ tk_send('sortbycolumn', _to_idx(idx))
+ end
+ self
+ end
+ def sort_by_column_increasing(idx)
+ tk_send('sortbycolumn', _to_idx(idx), '-increasing')
+ self
+ end
+ def sort_by_column_decreasing(idx)
+ tk_send('sortbycolumn', _to_idx(idx), '-decreasing')
+ self
+ end
+
+ def sort_by_columnlist(idxlist, orderlist=None)
+ # orderlist :: list of 'increasing' or 'decreasing'
+ tk_send('sortbycolumnlist', idxlist.map{|idx| _to_idx(idx)}, orderlist)
+ self
+ end
+
+ def sortcolumn
+ idx = num_or_str(tk_send('sortcolum'))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+
+ def sortcolumnlist
+ simplelist(tk_send('sortcolumlist')).map{|col| num_or_str(col)}
+ end
+
+ def sortorder
+ tk_send('sortorder')
+ end
+
+ def sortorderlist
+ simplelist(tk_send('sortorderlist'))
+ end
+
+ def toggle_columnhide(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglecolumnhide', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglecolumnhide', first, last)
+ end
+ end
+
+ def toggle_rowhide(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglerowhide', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglerowhide', first, last)
+ end
+ end
+
+ def toggle_visibility(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglevisibility', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglevisibility', first, last)
+ end
+ self
+ end
+ alias togglevisibility toggle_visibility
+
+ def unset_attrib(name)
+ tk_send('unsetattrib', name)
+ self
+ end
+
+ def unset_cellattrib(idx, name)
+ tk_send('unsetcellattrib', _to_idx(idx), name)
+ self
+ end
+
+ def unset_columnattrib(idx, name)
+ tk_send('unsetcolumnattrib', _to_idx(idx), name)
+ self
+ end
+
+ def unset_rowattrib(idx, name)
+ tk_send('unsetrowattrib', _to_idx(idx), name)
+ self
+ end
+
+ def windowpath(idx)
+ window(tk_send('windowpath', _to_idx(idx)))
+ end
+end
+
+class << Tk::Tcllib::Tablelist
+ ############################################################
+ # helper commands
+ def getTablelistPath(descendant)
+ window(Tk.tk_call('::tablelist::getTablelistPath', descendant))
+ end
+
+ def getTablelistColumn(descendant)
+ num_or_str(Tk.tk_call('::tablelist::getTablelistColumn', headerlabel))
+ end
+
+
+ def convEventFields(descendant, x, y)
+ window(Tk.tk_call('::tablelist::convEventFields', descendant, x, y))
+ end
+
+
+ ############################################################
+ # with the BWidget package
+ def addBWidgetEntry(name=None)
+ Tk.tk_call('::tablelist::addBWidgetEntry', name)
+ end
+
+ def addBWidgetSpinBox(name=None)
+ Tk.tk_call('::tablelist::addBWidgetSpinBox', name)
+ end
+
+ def addBWidgetComboBox(name=None)
+ Tk.tk_call('::tablelist::addBWidgetComboBox', name)
+ end
+
+
+ ############################################################
+ # with the Iwidgets ([incr Widgets]) package
+ def addIncrEntryfield(name=None)
+ Tk.tk_call('::tablelist::addIncrEntry', name)
+ end
+
+ def addIncrDateTimeWidget(type, seconds=false, name=None)
+ # type := 'datefield'|'dateentry'|timefield'|'timeentry'
+ if seconds && seconds != None
+ seconds = '-seconds'
+ else
+ seconds = None
+ end
+ Tk.tk_call('::tablelist::addDateTimeWidget', type, seconds, name)
+ end
+
+ def addIncrSpinner(name=None)
+ Tk.tk_call('::tablelist::addIncrSpinner', name)
+ end
+
+ def addIncrSpinint(name=None)
+ Tk.tk_call('::tablelist::addIncrSpinint', name)
+ end
+
+ def addIncrCombobox(name=None)
+ Tk.tk_call('::tablelist::addIncrCombobox', name)
+ end
+
+
+ ############################################################
+ # with Bryan Oakley's combobox package
+ def addOakleyCombobox(name=None)
+ Tk.tk_call('::tablelist::addOakleyCombobox', name)
+ end
+
+ ############################################################
+ # with the multi-entry package Mentry is a library extension
+ def addDateMentry(format, separator, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addDateMentry', format, separator, gmt, name)
+ end
+
+ def addTimeMentry(format, separator, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addTimeMentry', format, separator, gmt, name)
+ end
+
+ def addDateTimeMentry(format, date_sep, time_sep, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addDateTimeMentry',
+ format, date_sep, time_sep, gmt, name)
+ end
+
+ def addFixedPointMentry(count1, count2, comma=false, name=None)
+ if comma && comma != None
+ comma = '-comma'
+ else
+ comma = None
+ end
+ Tk.tk_call('::tablelist::addFixedPoingMentry', count1, count2, comma, name)
+ end
+
+ def addIPAddrMentry(name=None)
+ Tk.tk_call('::tablelist::addIPAddrMentry', name)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb
new file mode 100644
index 0000000..0a14584
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/tcllib/tablelist_tlie.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A multi-column listbox
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tablelist_tile', '4.2')
+TkPackage.require('tablelist_tile')
+
+unless defined? Tk::Tcllib::Tablelist_usingTile
+ Tk::Tcllib::Tablelist_usingTile = true
+end
+
+requrie 'tkextlib/tcllib/tablelist_core'
+
+module Tk
+ module Tcllib
+ class Tablelist
+ # commands related to tile Themems
+ def self.set_theme(theme)
+ Tk.tk_call('::tablelist::setTheme', theme)
+ end
+
+ def self.get_current_theme
+ Tk.tk_call('::tablelist::getCurrentTheme')
+ end
+
+ def self.get_theme_list
+ TkComm.simplelist(Tk.tk_call('::tablelist::getThemes'))
+ end
+ def self.set_theme_defaults
+ Tk.tk_call('::tablelist::setThemeDefaults')
+ end
+ end
+
+ Tablelist_Tile = Tablelist
+ TableList_Tile = Tablelist
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
new file mode 100644
index 0000000..2f6e4b4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
@@ -0,0 +1,314 @@
+#
+# tkextlib/tcllib/tkpiechart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create 2D or 3D pies with labels in Tcl canvases
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tkpiechart', '6.6')
+TkPackage.require('tkpiechart')
+
+module Tk
+ module Tcllib
+ module Tkpiechart
+ end
+ end
+end
+
+module Tk::Tcllib::Tkpiechart
+ PACKAGE_NAME = 'tkpiechart'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tkpiechart')
+ rescue
+ ''
+ end
+ end
+
+ module ConfigMethod
+ include TkConfigMethod
+
+ def __pathname
+ self.path + ';' + self.tag
+ end
+ private :__pathname
+
+ def __cget_cmd
+ ['::switched::cget', self.tag]
+ end
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ def __configinfo_struct
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>1, :current_value=>2}
+ end
+ private :__configinfo_struct
+
+ def __boolval_optkeys
+ super() << 'select' << 'autoupdate' << 'selectable'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'bordercolor' << 'textbackground' <<
+ 'widestvaluetext' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'colors'
+ end
+ private :__listval_optkeys
+ end
+
+ ####################################
+ class PieChartObj < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['titlefont']
+ end
+ private :__font_optkeys
+ end
+
+ ####################################
+ class Pie < TkcItem
+ include ConfigMethod
+
+ def create_self(x, y, width, height, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie',
+ @c, x, y, *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y)
+ end
+
+ @slice_tbl = {}
+
+ id = "pie(#{@tag_key})"
+
+ @tag = @tag_pie = TkcNamedTag(@c, id)
+ @tag_slices = TkcNamedTag(@c, "pieSlices(#{@tag_key})")
+
+ id
+ end
+ private :create_self
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def canvas
+ @c
+ end
+ def _entry_slice(slice)
+ @slice_tbl[slice.to_eval] = slice
+ end
+ def _delete_slice(slice)
+ @slice_tbl.delete(slice.to_eval)
+ end
+
+ def delete
+ tk_call_without_enc('::stooop::delete', @tag_key)
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ self
+ end
+
+ def new_slice(text=None)
+ Slice.new(self, text)
+ end
+
+ def delete_slice(slice)
+ unless slice.kind_of?(Slice)
+ unless (slice = @slice_tbl[slice])
+ return tk_call_without_enc('pie::deleteSlice', @tag_key, slice)
+ end
+ end
+ unless slice.kind_of?(Slice) && slice.pie == self
+ fail ArgumentError, "argument is not a slice of self"
+ end
+ slice.delete
+ end
+
+ def selected_slices
+ tk_split_simplelist(tk_call_without_enc('pie::selectedSlices',
+ @tag_key)).collect{|slice|
+ @slice_tbl[slice] || Slice.new(:no_create, self, slice)
+ }
+ end
+ end
+
+ ####################################
+ class Slice < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def initialize(pie, *args)
+ unless pie.kind_of?(Pie) && pie != :no_create
+ fail ArgumentError, "expects TkPiechart::Pie for 1st argument"
+ end
+
+ if pie == :no_create
+ @pie, @tag_key = args
+ else
+ text = args[0] || None
+ @pie = pie
+ @tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text)
+ end
+ @parent = @c = @pie.canvas
+ @path = @parent.path
+
+ @pie._entry_slice(self)
+
+ @id = "slices(#{@tag_key})"
+ @tag = TkcNamedTag.new(@pie.canvas, @id)
+
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ }
+ end
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def pie
+ @pie
+ end
+
+ def delete
+ tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key)
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ @pie._delete_slice(self)
+ self
+ end
+
+ def size(share, disp=None)
+ tk_call_without_enc('pie::sizeSlice',
+ @pie.tag_key, @tag_key, share, disp)
+ self
+ end
+
+ def label(text)
+ tk_call_without_enc('pie::labelSlice', @pie.tag_key, @tag_key, text)
+ self
+ end
+ end
+
+ ####################################
+ class BoxLabeler < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler')
+ end
+
+ id = "pieBoxLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class PeripheralLabeler < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['font', 'smallfont']
+ end
+ private :__font_optkeys
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new',
+ 'piePeripheralLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler')
+ end
+
+ id = "piePeripheralLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class Label < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(x, y, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height,
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height)
+ end
+
+ id = "canvasLabel(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb
new file mode 100644
index 0000000..6eae4eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/tcllib/toolbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * toolbar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::toolbar', '1.2')
+TkPackage.require('widget::toolbar')
+
+module Tk::Tcllib
+ module Widget
+ class Toolbar < TkWindow
+ PACKAGE_NAME = 'widget::toolbar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::toolbar')
+ rescue
+ ''
+ end
+ end
+ end
+
+ module ToolbarItemConfig
+ include TkItemConfigMethod
+ end
+ end
+end
+
+
+class Tk::Tcllib::Widget::ToolbarItem < TkObject
+ include TkTreatTagFont
+
+ ToolbarItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TTagID_TBL.mutex.synchronize{ TTagID_TBL.clear }
+ }
+
+ def ToolbarItem.id2obj(tbar, id)
+ tpath = tbar.path
+ ToolbarItemID_TBL.mutex.synchronize{
+ if ToolbarItemID_TBL[tpath]
+ ToolbarItemID_TBL[tpath][id]? ToolbarItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initaialize(parent, *args)
+ @parent = @t = parent
+ @tpath = parent.path
+
+ @path = @id = @t.tk_send('add', *args)
+ # A same id is rejected by the Tcl function.
+
+ ToolbarItemID_TBL.mutex.synchronize{
+ ToolbarItemID_TBL[@id] = self
+ ToolbarItemID_TBL[@tpath] = {} unless ToolbarItemID_TBL[@tpath]
+ ToolbarItemID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget_tkstring(option)
+ @t.itemcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.itemcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.itemcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.itemconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_itemconfiginfo(@id, key)
+ end
+
+ def delete
+ @t.delete(@id)
+ end
+
+ def itemid
+ @t.itemid(@id)
+ end
+
+ def remove
+ @t.remove(@id)
+ end
+ def remove_with_destroy
+ @t.remove_with_destroy(@id)
+ end
+end
+
+class Tk::Tcllib::Widget::Toolbar
+ include Tk::Tcllib::Widget::ToolbarItemConfig
+
+ TkCommandNames = ['::widget::toolbar'.freeze].freeze
+
+ def __destroy_hook__
+ Tk::Tcllib::Widget::ToolbarItem::ToolbarItemID_TBL.mutex.synchronize{
+ Tk::Tcllib::Widget::ToolbarItem::ToolbarItemID_TBL.delete(@path)
+ }
+ end
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send('getframe'))
+ end
+ alias get_frame getframe
+
+ def add(*args)
+ Tk::Tcllib::Widget::Toolbar.new(self, *args)
+ end
+
+ def itemid(item)
+ window(tk_send('itemid'))
+ end
+
+ def items(pattern)
+ tk_split_simplelist(tk_send('items', pattern)).map{|id|
+ Tk::Tcllib::Widget::ToolbarItem.id2obj(self, id)
+ }
+ end
+
+ def remove(*items)
+ tk_send('remove', *items)
+ self
+ end
+
+ def remove_with_destroy(*items)
+ tk_send('remove', '-destroy', *items)
+ self
+ end
+
+ def delete(*items)
+ tk_send('delete', *items)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb
new file mode 100644
index 0000000..070e63a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb
@@ -0,0 +1,104 @@
+#
+# tkextlib/tcllib/tooltip.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides tooltips, a small text message that is displayed when the
+# mouse hovers over a widget.
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tooltip', '1.1')
+TkPackage.require('tooltip')
+
+module Tk::Tcllib
+ module Tooltip
+ PACKAGE_NAME = 'tooltip'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tooltip')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Tooltip
+ extend TkCore
+
+ WidgetClassName = 'Tooltip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.database_classname
+ self::WidgetClassName
+ end
+ def self.database_class
+ WidgetClassNames[self::WidgetClassName]
+ end
+
+ def self.clear(glob_path_pat = None)
+ self.clear_glob(glob_path_pat)
+ end
+
+ def self.clear_glob(glob_path_pat)
+ tk_call_without_enc('::tooltip::tooltip', 'clear', glob_path_pat)
+ end
+
+ def self.clear_widgets(*args)
+ self.clear_glob("{#{args.collect{|w| _get_eval_string(w)}.join(',')}}")
+ end
+
+ def self.clear_children(*args)
+ self.clear_glob("{#{args.collect{|w| s = _get_eval_string(w); "#{s},#{s}.*"}.join(',')}}")
+ end
+
+ def self.delay(millisecs=None)
+ number(tk_call_without_enc('::tooltip::tooltip', 'delay', millisecs))
+ end
+ def self.delay=(millisecs)
+ self.delay(millisecs)
+ end
+
+ def self.fade?
+ bool(tk_call_without_enc('::tooltip::tooltip', 'fade'))
+ end
+ def self.fade(mode)
+ tk_call_without_enc('::tooltip::tooltip', 'fade', mode)
+ end
+
+ def self.disable
+ tk_call_without_enc('::tooltip::tooltip', 'disable')
+ false
+ end
+ def self.off
+ self.disable
+ end
+
+ def self.enable
+ tk_call_without_enc('::tooltip::tooltip', 'enable')
+ true
+ end
+ def self.on
+ self.enable
+ end
+
+ def self.register(widget, msg, keys=nil)
+ if keys.kind_of?(Hash)
+ args = hash_kv(keys) << msg
+ else
+ args = msg
+ end
+ tk_call('::tooltip::tooltip', widget.path, *args)
+ end
+
+ def self.erase(widget)
+ tk_call_without_enc('::tooltip::tooltip', widget.path, '')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb
new file mode 100644
index 0000000..3a71960
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb
@@ -0,0 +1,65 @@
+#
+# tkextlib/tcllib/validator.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides a unified validation API
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::validator', '0.1')
+TkPackage.require('widget::validator')
+
+module Tk::Tcllib
+ module Validator
+ PACKAGE_NAME = 'widget::validator'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::validator')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Validator
+ extend TkCore
+
+ def self.attach(widget, color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'attach', widget, color, cmd)
+ nil
+ end
+
+ def self.detach(widget)
+ tk_call_without_enc('::widget::validator', 'detach', widget)
+ nil
+ end
+
+ def self.validate(widget)
+ tk_call_without_enc('::widget::validator', 'validate', widget)
+ nil
+ end
+
+ def attach_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'attach', @path, color, cmd)
+ self
+ end
+
+ def detach_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'detach', @path)
+ self
+ end
+
+ def invoke_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'validate', @path)
+ self
+ end
+ alias validate_validator invoke_validator
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb
new file mode 100644
index 0000000..57fdf7a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb
@@ -0,0 +1,82 @@
+#
+# tkextlib/tcllib/widget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * megawidget package that uses snit as the object system (snidgets)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget', '3.0')
+TkPackage.require('widget')
+
+module Tk::Tcllib
+ module Widget
+ PACKAGE_NAME = 'widget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget')
+ rescue
+ ''
+ end
+ end
+
+ #--- followings may be private functions of tklib
+ def self.isa(compare_as, *args)
+ begin
+ return Tk.tk_call('::widget::isa', compare_as, *args)
+ rescue => e
+ if TkComm.bool(Tk.tk_call('info','command','::widget::isa')) ||
+ ! TkComm.bool(Tk.tk_call('info','command','::widget::validate'))
+ fail e
+ end
+ end
+ Tk.tk_call('::widget::validate', compare_as, *args)
+ end
+ def self.validate(compare_as, *args)
+ begin
+ return Tk.tk_call('::widget::validate', compare_as, *args)
+ rescue => e
+ if TkComm.bool(Tk.tk_call('info','command','::widget::validate')) ||
+ ! TkComm.bool(Tk.tk_call('info','command','::widget::isa'))
+ fail e
+ end
+ end
+ Tk.tk_call('::widget::isa', compare_as, *args)
+ end
+ end
+end
+
+module Tk::Tcllib::Widget
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ autoload :Calendar, 'tkextlib/tcllib/calendar'
+
+ autoload :Canvas_Sqmap, 'tkextlib/tcllib/canvas_sqmap'
+ autoload :Canvas_Zoom, 'tkextlib/tcllib/canvas_zoom'
+
+ autoload :Dialog, 'tkextlib/tcllib/dialog'
+
+ autoload :Panelframe, 'tkextlib/tcllib/panelframe'
+ autoload :PanelFrame, 'tkextlib/tcllib/panelframe'
+
+ autoload :Ruler, 'tkextlib/tcllib/ruler'
+
+ autoload :Screenruler, 'tkextlib/tcllib/screenruler'
+ autoload :ScreenRuler, 'tkextlib/tcllib/screenruler'
+
+ autoload :Scrolledwindow, 'tkextlib/tcllib/scrollwin'
+ autoload :ScrolledWindow, 'tkextlib/tcllib/scrollwin'
+
+ autoload :Superframe, 'tkextlib/tcllib/superframe'
+ autoload :SuperFrame, 'tkextlib/tcllib/superframe'
+
+ autoload :Toolbar, 'tkextlib/tcllib/toolbar'
+ autoload :ToolbarItem, 'tkextlib/tcllib/toolbar'
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tclx.rb b/jni/ruby/ext/tk/lib/tkextlib/tclx.rb
new file mode 100644
index 0000000..3a4ff27
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tclx.rb
@@ -0,0 +1,13 @@
+#
+# TclX support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tclx/setup.rb'
+
+# load library
+require 'tkextlib/tclx/tclx'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb b/jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb
new file mode 100644
index 0000000..5a908fc
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb
@@ -0,0 +1,74 @@
+#
+# tclx/tclx.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tclx/setup.rb'
+
+# TkPackage.require('Tclx', '8.0')
+TkPackage.require('Tclx')
+
+module Tk
+ module TclX
+ PACKAGE_NAME = 'Tclx'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Tclx')
+ rescue
+ ''
+ end
+ end
+
+ def self.infox(*args)
+ Tk.tk_call('infox', *args)
+ end
+
+ def self.signal(*args)
+ warn("Warning: Don't recommend to use TclX's 'signal' command. Please use Ruby's 'Signal.trap' method")
+ Tk.tk_call('signal', *args)
+ end
+
+ def self.signal_restart(*args)
+ warn("Warning: Don't recommend to use TclX's 'signal' command. Please use Ruby's 'Signal.trap' method")
+ Tk.tk_call('signal', '-restart', *args)
+ end
+
+ ##############################
+
+ class XPG3_MsgCat
+ class << self
+ alias open new
+ end
+
+ def initialize(catname, fail_mode=false)
+ if fail_mode
+ @msgcat_id = Tk.tk_call('catopen', '-fail', catname)
+ else
+ @msgcat_id = Tk.tk_call('catopen', '-nofail', catname)
+ end
+ end
+
+ def close(fail_mode=false)
+ if fail_mode
+ Tk.tk_call('catclose', '-fail', @msgcat_id)
+ else
+ Tk.tk_call('catclose', '-nofail', @msgcat_id)
+ end
+ self
+ end
+
+ def get(setnum, msgnum, defaultstr)
+ Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile.rb b/jni/ruby/ext/tk/lib/tkextlib/tile.rb
new file mode 100644
index 0000000..6c11e21
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile.rb
@@ -0,0 +1,449 @@
+#
+# Tile theme engin (tile widget set) support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/ttk_selector'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# library directory
+require 'tkextlib/tile/setup.rb'
+
+# load package
+# TkPackage.require('tile', '0.4')
+# TkPackage.require('tile', '0.6')
+# TkPackage.require('tile', '0.7')
+if Tk::TK_MAJOR_VERSION > 8 ||
+ (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION >= 5)
+ begin
+ TkPackage.require('tile') # for compatibility (version check of 'tile')
+ rescue RuntimeError
+ # ignore, even if cannot find package 'tile'
+ end
+ pkgname = 'Ttk'
+else
+ pkgname = 'tile'
+end
+
+begin
+ verstr = TkPackage.require(pkgname)
+rescue RuntimeError
+ # define dummy methods
+ module Tk
+ module Tile
+ CANNOT_FIND_PACKAGE = true
+ def self.const_missing(sym)
+ TkPackage.require(PACKAGE_NAME)
+ end
+ def self.method_missing(*args)
+ TkPackage.require(PACKAGE_NAME)
+ end
+ end
+ end
+ Tk.__cannot_find_tk_package_for_widget_set__(:Ttk, pkgname)
+ if pkgname == 'Ttk'
+ verstr = Tk::TK_PATCHLEVEL # dummy
+ else
+ verstr = '0.7' # dummy
+ end
+end
+
+ver = verstr.split('.')
+if ver[0].to_i == 0
+ # Tile extension package
+ if ver[1].to_i <= 4
+ # version 0.4 or former
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = true
+ USE_TTK_NAMESPACE = false
+ TILE_SPEC_VERSION_ID = 0
+ end
+ end
+ elsif ver[1].to_i <= 6
+ # version 0.5 -- version 0.6
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = true
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 5
+ end
+ end
+ elsif ver[1].to_i <= 7
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 7
+ end
+ end
+ else
+ # version 0.8 or later
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 8
+ end
+ end
+ end
+
+ module Tk::Tile
+ PACKAGE_NAME = 'tile'.freeze
+ end
+else
+ # Ttk package merged Tcl/Tk core (Tcl/Tk 8.5+)
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 8
+
+ PACKAGE_NAME = 'Ttk'.freeze
+ end
+ end
+end
+
+# autoload
+module Tk
+ module Tile
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require(PACKAGE_NAME)
+ rescue
+ ''
+ end
+ end
+
+ def self.__Import_Tile_Widgets__!
+ warn 'Warning: "Tk::Tile::__Import_Tile_Widgets__!" is obsolete.' <<
+ ' To control default widget set, use "Tk.default_widget_set = :Ttk"'
+ Tk.tk_call('namespace', 'import', '-force', 'ttk::*')
+ end
+
+ def self.__define_LoadImages_proc_for_compatibility__!
+ # Ttk 8.5 (Tile 0.8) lost 'LoadImages' utility procedure.
+ # So, some old scripts doen't work, because those scripts use the
+ # procedure to define local styles.
+ # Of course, rewriting such Tcl/Tk scripts isn't difficult for
+ # Tcl/Tk users. However, it may be troublesome for Ruby/Tk users
+ # who use such Tcl/Tk scripts as it is.
+ # This method may help Ruby/Tk users who don't want to modify old
+ # Tcl/Tk scripts for the latest version of Ttk (Tile) extension.
+ # This method defines a comaptible 'LoadImages' procedure on the
+ # Tcl/Tk interpreter working under Ruby/Tk.
+ # Please give attention to use this method. It may conflict with
+ # some definitions on Tcl/Tk scripts.
+ klass_name = self.name
+ proc_name = 'LoadImages'
+ if Tk::Tile::USE_TTK_NAMESPACE
+ ns_list = ['::tile']
+ if Tk.info(:commands, "::ttk::#{proc_name}").empty?
+ ns_list << '::ttk'
+ end
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ ns_list = ['::ttk']
+ if Tk.info(:commands, "::tile::#{proc_name}").empty?
+ ns_list << '::tile'
+ end
+ end
+
+ ns_list.each{|ns|
+ cmd = "#{ns}::#{proc_name}"
+ unless Tk.info(:commands, cmd).empty?
+ #fail RuntimeError, "can't define '#{cmd}' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '#{cmd}' command (already exist)" if $DEBUG
+ next
+ end
+ TkNamespace.eval(ns){
+ TkCore::INTERP.add_tk_procs(proc_name, 'imgdir {patterns {*.gif}}',
+ <<-'EOS')
+ foreach pattern $patterns {
+ foreach file [glob -directory $imgdir $pattern] {
+ set img [file tail [file rootname $file]]
+ if {![info exists images($img)]} {
+ set images($img) [image create photo -file $file]
+ }
+ }
+ }
+ return [array get images]
+ EOS
+ }
+ }
+ end
+
+ def self.load_images(imgdir, pat=nil)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ if Tk::Tile::USE_TTK_NAMESPACE
+ cmd = '::ttk::LoadImages'
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ cmd = '::tile::LoadImages'
+ end
+ pat ||= TkComm::None
+ images = Hash[*TkComm.simplelist(Tk.tk_call(cmd, imgdir, pat))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ else ## TILE_SPEC_VERSION_ID >= 8
+ pat ||= '*.gif'
+ if pat.kind_of?(Array)
+ pat_list = pat
+ else
+ pat_list = [ pat ]
+ end
+ Dir.chdir(imgdir){
+ pat_list.each{|pat|
+ Dir.glob(pat).each{|f|
+ img = File.basename(f, '.*')
+ unless TkComm.bool(Tk.info('exists', "images(#{img})"))
+ Tk.tk_call('set', "images(#{img})",
+ Tk.tk_call('image', 'create', 'photo', '-file', f))
+ end
+ }
+ }
+ }
+ images = Hash[*TkComm.simplelist(Tk.tk_call('array', 'get', 'images'))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ end
+
+ images
+ end
+
+ def self.style(*args)
+ args.map!{|arg| TkComm._get_eval_string(arg)}.join('.')
+ end
+
+ def self.themes(glob_ptn = nil)
+ if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::themes').empty?
+ fail RuntimeError, 'not support glob option' if glob_ptn
+ cmd = ['::tile::availableThemes']
+ else
+ glob_ptn = '*' unless glob_ptn
+ cmd = ['::ttk::themes', glob_ptn]
+ end
+
+ begin
+ TkComm.simplelist(Tk.tk_call_without_enc(*cmd))
+ rescue
+ TkComm.simplelist(Tk.tk_call('lsearch', '-all', '-inline',
+ Tk::Tile::Style.theme_names,
+ glob_ptn))
+ end
+ end
+
+ def self.set_theme(theme)
+ if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::setTheme').empty?
+ cmd = '::tile::setTheme'
+ else
+ cmd = '::ttk::setTheme'
+ end
+
+ begin
+ Tk.tk_call_without_enc(cmd, theme)
+ rescue
+ Tk::Tile::Style.theme_use(theme)
+ end
+ end
+
+ module KeyNav
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ def self.enableMnemonics(w)
+ Tk.tk_call('::keynav::enableMnemonics', w)
+ end
+ def self.defaultButton(w)
+ Tk.tk_call('::keynav::defaultButton', w)
+ end
+ else # dummy
+ def self.enableMnemonics(w)
+ ""
+ end
+ def self.defaultButton(w)
+ ""
+ end
+ end
+ end
+
+ module Font
+ Default = 'TkDefaultFont'
+ Text = 'TkTextFont'
+ Heading = 'TkHeadingFont'
+ Caption = 'TkCaptionFont'
+ Tooltip = 'TkTooltipFont'
+
+ Fixed = 'TkFixedFont'
+ Menu = 'TkMenuFont'
+ SmallCaption = 'TkSmallCaptionFont'
+ Icon = 'TkIconFont'
+
+ TkFont::SYSTEM_FONT_NAMES.add [
+ 'TkDefaultFont', 'TkTextFont', 'TkHeadingFont',
+ 'TkCaptionFont', 'TkTooltipFont', 'TkFixedFont',
+ 'TkMenuFont', 'TkSmallCaptionFont', 'TkIconFont'
+ ]
+ end
+
+ module ParseStyleLayout
+ def _style_layout(lst)
+ ret = []
+ until lst.empty?
+ sub = [lst.shift]
+ keys = {}
+
+ until lst.empty?
+ if lst[0][0] == ?-
+ k = lst.shift[1..-1]
+ children = lst.shift
+ children = _style_layout(children) if children.kind_of?(Array)
+ keys[k] = children
+ else
+ break
+ end
+ end
+
+ sub << keys unless keys.empty?
+ ret << sub
+ end
+ ret
+ end
+ private :_style_layout
+ end
+
+ module TileWidget
+ include Tk::Tile::ParseStyleLayout
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ super().update('style'=>proc{|v| _style_layout(list(v))})
+ end
+ private :__val2ruby_optkeys
+
+ def ttk_instate(state, script=nil, &b)
+ if script
+ tk_send('instate', state, script)
+ elsif b
+ tk_send('instate', state, Proc.new(&b))
+ else
+ bool(tk_send('instate', state))
+ end
+ end
+ alias tile_instate ttk_instate
+
+ def ttk_state(state=nil)
+ if state
+ tk_send('state', state)
+ else
+ list(tk_send('state'))
+ end
+ end
+ alias tile_state ttk_state
+
+ def ttk_identify(x, y)
+ ret = tk_send_without_enc('identify', x, y)
+ (ret.empty?)? nil: ret
+ end
+ alias tile_identify ttk_identify
+
+ # remove instate/state/identify method
+ # to avoid the conflict with widget options
+ if Tk.const_defined?(:USE_OBSOLETE_TILE_STATE_METHOD) && Tk::USE_OBSOLETE_TILE_STATE_METHOD
+ alias instate ttk_instate
+ alias state ttk_state
+ alias identify ttk_identify
+ end
+ end
+
+ ######################################
+
+ autoload :TButton, 'tkextlib/tile/tbutton'
+ autoload :Button, 'tkextlib/tile/tbutton'
+
+ autoload :TCheckButton, 'tkextlib/tile/tcheckbutton'
+ autoload :CheckButton, 'tkextlib/tile/tcheckbutton'
+ autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton'
+ autoload :Checkbutton, 'tkextlib/tile/tcheckbutton'
+
+ autoload :Dialog, 'tkextlib/tile/dialog'
+
+ autoload :TEntry, 'tkextlib/tile/tentry'
+ autoload :Entry, 'tkextlib/tile/tentry'
+
+ autoload :TCombobox, 'tkextlib/tile/tcombobox'
+ autoload :Combobox, 'tkextlib/tile/tcombobox'
+
+ autoload :TFrame, 'tkextlib/tile/tframe'
+ autoload :Frame, 'tkextlib/tile/tframe'
+
+ autoload :TLabelframe, 'tkextlib/tile/tlabelframe'
+ autoload :Labelframe, 'tkextlib/tile/tlabelframe'
+ autoload :TLabelFrame, 'tkextlib/tile/tlabelframe'
+ autoload :LabelFrame, 'tkextlib/tile/tlabelframe'
+
+ autoload :TLabel, 'tkextlib/tile/tlabel'
+ autoload :Label, 'tkextlib/tile/tlabel'
+
+ autoload :TMenubutton, 'tkextlib/tile/tmenubutton'
+ autoload :Menubutton, 'tkextlib/tile/tmenubutton'
+ autoload :TMenuButton, 'tkextlib/tile/tmenubutton'
+ autoload :MenuButton, 'tkextlib/tile/tmenubutton'
+
+ autoload :TNotebook, 'tkextlib/tile/tnotebook'
+ autoload :Notebook, 'tkextlib/tile/tnotebook'
+
+ autoload :TPaned, 'tkextlib/tile/tpaned'
+ autoload :Paned, 'tkextlib/tile/tpaned'
+ autoload :PanedWindow, 'tkextlib/tile/tpaned'
+ autoload :Panedwindow, 'tkextlib/tile/tpaned'
+
+ autoload :TProgressbar, 'tkextlib/tile/tprogressbar'
+ autoload :Progressbar, 'tkextlib/tile/tprogressbar'
+
+ autoload :TRadioButton, 'tkextlib/tile/tradiobutton'
+ autoload :RadioButton, 'tkextlib/tile/tradiobutton'
+ autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
+ autoload :Radiobutton, 'tkextlib/tile/tradiobutton'
+
+ autoload :TScale, 'tkextlib/tile/tscale'
+ autoload :Scale, 'tkextlib/tile/tscale'
+ autoload :TProgress, 'tkextlib/tile/tscale'
+ autoload :Progress, 'tkextlib/tile/tscale'
+
+ autoload :TScrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :Scrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :XScrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :YScrollbar, 'tkextlib/tile/tscrollbar'
+
+ autoload :TSeparator, 'tkextlib/tile/tseparator'
+ autoload :Separator, 'tkextlib/tile/tseparator'
+
+ autoload :TSpinbox, 'tkextlib/tile/tspinbox'
+ autoload :Spinbox, 'tkextlib/tile/tspinbox'
+
+ autoload :TSquare, 'tkextlib/tile/tsquare'
+ autoload :Square, 'tkextlib/tile/tsquare'
+
+ autoload :SizeGrip, 'tkextlib/tile/sizegrip'
+ autoload :Sizegrip, 'tkextlib/tile/sizegrip'
+
+ autoload :Treeview, 'tkextlib/tile/treeview'
+
+ autoload :Style, 'tkextlib/tile/style'
+ end
+end
+
+Ttk = Tk::Tile
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb
new file mode 100644
index 0000000..b112e61
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb
@@ -0,0 +1,102 @@
+#
+# ttk::dialog (tile-0.7+)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class Dialog < TkWindow
+ end
+ end
+end
+
+begin
+ TkPackage.require('ttk::dialog') # this may be required.
+rescue RuntimeError
+ # ignore
+end
+
+class Tk::Tile::Dialog
+ TkCommandNames = ['::ttk::dialog'.freeze].freeze
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def self.define_dialog_type(name, keys)
+ Tk.tk_call('::ttk::dialog::define', name, keys)
+ name
+ end
+
+ def self.style(*args)
+ ['Dialog', *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ #########################
+
+ def initialize(keys={})
+ @keys = _symbolkey2str(keys)
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+ alias display show
+
+ def client_frame
+ window(tk_call_without_enc('::ttk::dialog::clientframe', @path))
+ end
+
+ def cget_strict(slot)
+ @keys[slot.to_s]
+ end
+ def cget(slot)
+ @keys[slot.to_s]
+ end
+=begin
+ def cget(slot)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ cget_strict(slot)
+ else
+ cget_strict(slot) rescue nil
+ end
+ end
+=end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ @keys[slot] = value
+ else
+ @keys.delete(slot)
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ [ slot, nil, nil, nil, @keys[slot] ]
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] }
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb
new file mode 100644
index 0000000..9947e0d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb
@@ -0,0 +1,32 @@
+#
+# ttk::sizegrip widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class SizeGrip < TkWindow
+ end
+ Sizegrip = SizeGrip
+ end
+end
+
+class Tk::Tile::SizeGrip < TkWindow
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['::ttk::sizegrip'.freeze].freeze
+ WidgetClassName = 'TSizegrip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Sizegrip,
+# :TkSizegrip, :TkSizeGrip)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/sizegrip.rb',
+ :Ttk, Tk::Tile::Sizegrip,
+ :TkSizegrip, :TkSizeGrip)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/style.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/style.rb
new file mode 100644
index 0000000..83a0c9a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/style.rb
@@ -0,0 +1,336 @@
+#
+# style commands
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ module Style
+ end
+ end
+end
+
+module Tk::Tile::Style
+ extend TkCore
+end
+
+class << Tk::Tile::Style
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ TkCommandNames = ['style'.freeze].freeze
+
+ # --- Tk::Tile::Style.__define_wrapper_proc_for_compatibility__! ---
+ # On Ttk (Tile) extension, 'style' command has incompatible changes
+ # depend on the version of the extension. It requires modifying the
+ # Tcl/Tk scripts to define local styles. The rule for modification
+ # is a simple one. But, if users want to keep compatibility between
+ # versions of the extension, they will have to contrive to do that.
+ # It may be troublesome, especially for Ruby/Tk users.
+ # This method may help such work. This method make some definitions
+ # on the Tcl/Tk interpreter to work with different version of style
+ # command format. Please give attention to use this method. It may
+ # conflict with some definitions on Tcl/Tk scripts.
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::ttk::style').empty?
+ # fail RuntimeError,
+ # "can't define '::ttk::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]
+ }
+ }
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ else ### TILE_SPEC_VERSION_ID == 7
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::ttk::style').empty?
+ # fail RuntimeError,
+ # "can't define '::ttk::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ end
+ else ### TILE_SPEC_VERSION_ID >= 8
+ TkCommandNames = ['::ttk::style'.freeze].freeze
+
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::style').empty?
+ # fail RuntimeError, "can't define '::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set name [lindex $args 4]
+ set opts [lrange $args 5 end]
+ set idx [lsearch $opts -map]
+ if {$idx >= 0 && [expr $idx % 2 == 0]} {
+ # return [eval [concat [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]]
+ return [uplevel 1 [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::ttk::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::ttk::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::ttk::style $args"]
+ return [uplevel 1 ::ttk::style $args]
+ EOS
+ #########################
+ end
+ end
+
+ def __define_themes_and_setTheme_proc__!
+ TkCore::INTERP.add_tk_procs('::ttk::themes', '{ptn *}', <<-'EOS')
+ #set themes [list]
+ set themes [::ttk::style theme names]
+ foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
+ set theme [namespace tail $pkg]
+ if {[lsearch -exact $themes $theme] < 0} {
+ lappend themes $theme
+ }
+ }
+ foreach pkg [lsearch -inline -all -glob [package names] tile::theme::$ptn] {
+ set theme [namespace tail $pkg]
+ if {[lsearch -exact $themes $theme] < 0} {
+ lappend themes $theme
+ }
+ }
+ return $themes
+ EOS
+ #########################
+ TkCore::INTERP.add_tk_procs('::ttk::setTheme', 'theme', <<-'EOS')
+ variable currentTheme
+ if {[lsearch -exact [::ttk::style theme names] $theme] < 0} {
+ package require [lsearch -inline -regexp [package names] (ttk|tile)::theme::$theme]
+ }
+ ::ttk::style theme use $theme
+ set currentTheme $theme
+ EOS
+ end
+ private :__define_themes_and_setTheme_proc__!
+
+ def configure(style=nil, keys=nil)
+ if style.kind_of?(Hash)
+ keys = style
+ style = nil
+ end
+ style = '.' unless style
+
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ sub_cmd = 'default'
+ else
+ sub_cmd = 'configure'
+ end
+
+ if keys && keys != None
+ tk_call(TkCommandNames[0], sub_cmd, style, *hash_kv(keys))
+ else
+ tk_call(TkCommandNames[0], sub_cmd, style)
+ end
+ end
+ alias default configure
+
+ def map(style=nil, keys=nil)
+ if style.kind_of?(Hash)
+ keys = style
+ style = nil
+ end
+ style = '.' unless style
+
+ if keys && keys != None
+ if keys.kind_of?(Hash)
+ tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
+ else
+ simplelist(tk_call(TkCommandNames[0], 'map', style, '-' << keys.to_s))
+ end
+ else
+ ret = {}
+ Hash[*(simplelist(tk_call(TkCommandNames[0], 'map', style)))].each{|k, v|
+ ret[k[1..-1]] = list(v)
+ }
+ ret
+ end
+ end
+ alias map_configure map
+
+ def map_configinfo(style=nil, key=None)
+ style = '.' unless style
+ map(style, key)
+ end
+
+ def map_default_configinfo(key=None)
+ map('.', key)
+ end
+
+ def lookup(style, opt, state=None, fallback_value=None)
+ tk_call(TkCommandNames[0], 'lookup', style,
+ '-' << opt.to_s, state, fallback_value)
+ end
+
+ include Tk::Tile::ParseStyleLayout
+
+ def layout(style=nil, spec=nil)
+ if style.kind_of?(Hash)
+ spec = style
+ style = nil
+ end
+ style = '.' unless style
+
+ if spec
+ tk_call(TkCommandNames[0], 'layout', style, spec)
+ else
+ _style_layout(list(tk_call(TkCommandNames[0], 'layout', style)))
+ end
+ end
+
+ def element_create(name, type, *args)
+ if type == 'image' || type == :image
+ element_create_image(name, *args)
+ elsif type == 'vsapi' || type == :vsapi
+ element_create_vsapi(name, *args)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
+ end
+ end
+
+ def element_create_image(name, *args)
+ fail ArgumentError, 'Must supply a base image' unless (spec = args.shift)
+ if (opts = args.shift)
+ if opts.kind_of?(Hash)
+ opts = _symbolkey2str(opts)
+ else
+ fail ArgumentError, 'bad option'
+ end
+ end
+ fail ArgumentError, 'too many arguments' unless args.empty?
+
+ if spec.kind_of?(Array)
+ # probably, command format is tile 0.8+ (Tcl/Tk8.5+) style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ else
+ fail ArgumentError, 'illegal arguments' if opts.key?('map')
+ base = spec.shift
+ opts['map'] = spec
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', base, opts)
+ end
+ else
+ # probably, command format is tile 0.7.8 or older style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ spec = [spec, *(opts.delete('map'))] if opts.key?('map')
+ end
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ end
+ end
+
+ def element_create_vsapi(name, class_name, part_id, *args)
+ # supported on Tcl/Tk 8.6 or later
+
+ # argument check
+ if (state_map = args.shift || None)
+ if state_map.kind_of?(Hash)
+ opts = _symbolkey2str(state_map)
+ state_map = None
+ end
+ end
+ opts = args.shift || None
+ fail ArgumentError, "too many arguments" unless args.empty?
+
+ # define a Microsoft Visual Styles element
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'vsapi',
+ class_name, part_id, state_map, opts)
+ end
+
+ def element_names()
+ list(tk_call(TkCommandNames[0], 'element', 'names'))
+ end
+
+ def element_options(elem)
+ simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem))
+ end
+
+ def theme_create(name, keys=nil)
+ name = name.to_s
+ if keys && keys != None
+ tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys))
+ else
+ tk_call(TkCommandNames[0], 'theme', 'create', name)
+ end
+ name
+ end
+
+ def theme_settings(name, cmd=nil, &b)
+ name = name.to_s
+ cmd = Proc.new(&b) if !cmd && b
+ tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
+ name
+ end
+
+ def theme_names()
+ list(tk_call(TkCommandNames[0], 'theme', 'names'))
+ end
+
+ def theme_use(name)
+ name = name.to_s
+ tk_call(TkCommandNames[0], 'theme', 'use', name)
+ name
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb
new file mode 100644
index 0000000..c852024
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb
@@ -0,0 +1,34 @@
+#
+# tbutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TButton < Tk::Button
+ end
+ Button = TButton
+ end
+end
+
+class Tk::Tile::TButton < Tk::Button
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::button'.freeze].freeze
+ else
+ TkCommandNames = ['::tbutton'.freeze].freeze
+ end
+ WidgetClassName = 'TButton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Button, :TkButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tbutton.rb',
+ :Ttk, Tk::Tile::Button, :TkButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
new file mode 100644
index 0000000..01751ed
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
@@ -0,0 +1,38 @@
+#
+# tcheckbutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TCheckButton < Tk::CheckButton
+ end
+ TCheckbutton = TCheckButton
+ CheckButton = TCheckButton
+ Checkbutton = TCheckButton
+ end
+end
+
+class Tk::Tile::TCheckButton < Tk::CheckButton
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::checkbutton'.freeze].freeze
+ else
+ TkCommandNames = ['::tcheckbutton'.freeze].freeze
+ end
+ WidgetClassName = 'TCheckbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Checkbutton,
+# :TkCheckbutton, :TkCheckButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tcheckbutton.rb',
+ :Ttk, Tk::Tile::Checkbutton,
+ :TkCheckbutton, :TkCheckButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb
new file mode 100644
index 0000000..b5ab827
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb
@@ -0,0 +1,55 @@
+#
+# tcombobox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TCombobox < Tk::Tile::TEntry
+ end
+ Combobox = TCombobox
+ end
+end
+
+class Tk::Tile::TCombobox < Tk::Tile::TEntry
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::combobox'.freeze].freeze
+ else
+ TkCommandNames = ['::tcombobox'.freeze].freeze
+ end
+ WidgetClassName = 'TCombobox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'exportselection'
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def current
+ number(tk_send_without_enc('current'))
+ end
+ def current=(idx)
+ tk_send_without_enc('current', idx)
+ end
+
+ def set(val)
+ tk_send('set', val)
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Combobox, :TkCombobox)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tcombobox.rb',
+ :Ttk, Tk::Tile::Combobox, :TkCombobox)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb
new file mode 100644
index 0000000..8d2633a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb
@@ -0,0 +1,49 @@
+#
+# tentry widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TEntry < Tk::Entry
+ end
+ Entry = TEntry
+ end
+end
+
+class Tk::Tile::TEntry < Tk::Entry
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::entry'.freeze].freeze
+ else
+ TkCommandNames = ['::tentry'.freeze].freeze
+ end
+ WidgetClassName = 'TEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __optkey_aliases
+ {:vcmd=>:validatecommand, :invcmd=>:invalidcommand}
+ end
+ private :__optkey_aliases
+
+ def __boolval_optkeys
+ super() << 'exportselection'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'show'
+ end
+ private :__strval_optkeys
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Entry, :TkEntry)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tentry.rb',
+ :Ttk, Tk::Tile::Entry, :TkEntry)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb
new file mode 100644
index 0000000..d6d4312
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb
@@ -0,0 +1,34 @@
+#
+# tframe widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TFrame < Tk::Frame
+ end
+ Frame = TFrame
+ end
+end
+
+class Tk::Tile::TFrame < Tk::Frame
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::frame'.freeze].freeze
+ else
+ TkCommandNames = ['::tframe'.freeze].freeze
+ end
+ WidgetClassName = 'TFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Frame, :TkFrame)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tframe.rb',
+ :Ttk, Tk::Tile::Frame, :TkFrame)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb
new file mode 100644
index 0000000..55b98ac
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb
@@ -0,0 +1,34 @@
+#
+# tlabel widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TLabel < Tk::Label
+ end
+ Label = TLabel
+ end
+end
+
+class Tk::Tile::TLabel < Tk::Label
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::label'.freeze].freeze
+ else
+ TkCommandNames = ['::tlabel'.freeze].freeze
+ end
+ WidgetClassName = 'TLabel'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Label, :TkLabel)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tlabel.rb',
+ :Ttk, Tk::Tile::Label, :TkLabel)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb
new file mode 100644
index 0000000..a34c985
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb
@@ -0,0 +1,38 @@
+#
+# tlabelframe widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TLabelframe < Tk::Tile::TFrame
+ end
+ TLabelFrame = TLabelframe
+ Labelframe = TLabelframe
+ LabelFrame = TLabelframe
+ end
+end
+
+class Tk::Tile::TLabelframe < Tk::Tile::TFrame
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::labelframe'.freeze].freeze
+ else
+ TkCommandNames = ['::tlabelframe'.freeze].freeze
+ end
+ WidgetClassName = 'TLabelframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Labelframe,
+# :TkLabelframe, :TkLabelFrame)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tlabelframe.rb',
+ :Ttk, Tk::Tile::Labelframe,
+ :TkLabelframe, :TkLabelFrame)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb
new file mode 100644
index 0000000..1cf553e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb
@@ -0,0 +1,38 @@
+#
+# tmenubutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TMenubutton < Tk::Menubutton
+ end
+ TMenuButton = TMenubutton
+ Menubutton = TMenubutton
+ MenuButton = TMenubutton
+ end
+end
+
+class Tk::Tile::TMenubutton < Tk::Menubutton
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::menubutton'.freeze].freeze
+ else
+ TkCommandNames = ['::tmenubutton'.freeze].freeze
+ end
+ WidgetClassName = 'TMenubutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Menubutton,
+# :TkMenubutton, :TkMenuButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tmenubutton.rb',
+ :Ttk, Tk::Tile::Menubutton,
+ :TkMenubutton, :TkMenuButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb
new file mode 100644
index 0000000..9e27e2c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -0,0 +1,147 @@
+#
+# tnotebook widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TNotebook < TkWindow
+ end
+ Notebook = TNotebook
+ end
+end
+
+class Tk::Tile::TNotebook < TkWindow
+ ################################
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tab', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tab', id]
+ end
+ private :__item_config_cmd
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_methodcall_optkeys(id) # { key=>method, ... }
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ #alias tabcget itemcget
+ #alias tabcget_strict itemcget_strict
+ alias tabconfigure itemconfigure
+ alias tabconfiginfo itemconfiginfo
+ alias current_tabconfiginfo current_itemconfiginfo
+
+ def tabcget_tkstring(tagOrId, option)
+ tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{option}")), false, true)[-1]
+ end
+ def tabcget_strict(tagOrId, option)
+ tabconfiginfo(tagOrId, option)[-1]
+ end
+ def tabcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tabcget_strict(tagOrId, option)
+ else
+ begin
+ tabcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_tabconfiginfo(tagOrId).has_key?(option.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ ################################
+
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::notebook'.freeze].freeze
+ else
+ TkCommandNames = ['::tnotebook'.freeze].freeze
+ end
+ WidgetClassName = 'TNotebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def enable_traversal()
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 5
+ tk_call_without_enc('::tile::enableNotebookTraversal', @path)
+ elsif Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ tk_call_without_enc('::tile::notebook::enableTraversal', @path)
+ else
+ tk_call_without_enc('::ttk::notebook::enableTraversal', @path)
+ end
+ self
+ end
+
+ def add(child, keys=nil)
+ if keys && keys != None
+ tk_send('add', _epath(child), *hash_kv(keys))
+ else
+ tk_send('add', _epath(child))
+ end
+ self
+ end
+
+ def forget(idx)
+ tk_send('forget', idx)
+ self
+ end
+
+ def hide(idx)
+ tk_send('hide', idx)
+ end
+
+ def index(idx)
+ number(tk_send('index', idx))
+ end
+
+ def insert(idx, subwin, keys=nil)
+ if keys && keys != None
+ tk_send('insert', idx, subwin, *hash_kv(keys))
+ else
+ tk_send('insert', idx, subwin)
+ end
+ self
+ end
+
+ def select(idx)
+ tk_send('select', idx)
+ self
+ end
+
+ def selected
+ window(tk_send_without_enc('select'))
+ end
+
+ def tabs
+ list(tk_send('tabs'))
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Notebook, :TkNotebook)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tnotebook.rb',
+ :Ttk, Tk::Tile::Notebook, :TkNotebook)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb
new file mode 100644
index 0000000..d6ad234
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb
@@ -0,0 +1,245 @@
+#
+# tpaned widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TPaned < TkWindow
+ end
+ PanedWindow = Panedwindow = Paned = TPaned
+ end
+end
+
+class Tk::Tile::TPaned < TkWindow
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ TkCommandNames = ['::ttk::paned'.freeze].freeze
+ else
+ TkCommandNames = ['::ttk::panedwindow'.freeze].freeze
+ end
+ else
+ TkCommandNames = ['::tpaned'.freeze].freeze
+ end
+ WidgetClassName = 'TPaned'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def add(*args)
+ keys = args.pop
+ fail ArgumentError, "no window in arguments" unless keys
+
+ if keys && keys.kind_of?(Hash)
+ fail ArgumentError, "no window in arguments" if args == []
+ opts = hash_kv(keys)
+ else
+ args.push(keys) if keys
+ opts = []
+ end
+
+ args.each{|win|
+ tk_send_without_enc('add', _epath(win), *opts)
+ }
+ self
+ end
+
+ def forget(pane)
+ pane = _epath(pane)
+ tk_send_without_enc('forget', pane)
+ self
+ end
+
+ def insert(pos, win, keys)
+ win = _epath(win)
+ tk_send_without_enc('insert', pos, win, *hash_kv(keys))
+ self
+ end
+
+ def panecget_tkstring(pane, slot)
+ pane = _epath(pane)
+ tk_send_without_enc('pane', pane, "-#{slot}")
+ end
+ alias pane_cget_tkstring panecget_tkstring
+
+ def panecget_strict(pane, slot)
+ pane = _epath(pane)
+ tk_tcl2ruby(tk_send_without_enc('pane', pane, "-#{slot}"))
+ end
+ alias pane_cget_strict panecget_strict
+
+ def panecget(pane, slot)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ panecget_strict(pane, slot)
+ else
+ begin
+ panecget_strict(pane, slot)
+ rescue => e
+ begin
+ if current_paneconfiginfo(pane).has_key?(slot.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ alias pane_cget panecget
+
+ def paneconfigure(pane, key, value=nil)
+ pane = _epath(pane)
+ if key.kind_of? Hash
+ params = []
+ key.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_send_without_enc('pane', pane, *params)
+ else
+ # value = value.epath if value.kind_of?(TkObject)
+ value = _epath(value)
+ tk_send_without_enc('pane', pane, "-#{key}", value)
+ end
+ self
+ end
+ alias pane_config paneconfigure
+ alias pane_configure paneconfigure
+
+ def paneconfiginfo(win)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ win = _epath(win)
+ if key
+ conf = tk_split_list(tk_send_without_enc('pane', win, "-#{key}"))
+ conf[0] = conf[0][1..-1]
+ if conf[0] == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ conf[4] = bool(conf[4]) unless conf[4].empty?
+ end
+ conf
+ else
+ tk_split_simplelist(tk_send_without_enc('pane',
+ win)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ if conf[3]
+ if conf[0] == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ elsif conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[0] == 'hide'
+ conf[4] = bool(conf[4]) unless conf[4].empty?
+ elsif conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ win = _epath(win)
+ if key
+ conf = tk_split_list(tk_send_without_enc('pane', win, "-#{key}"))
+ key = conf.shift[1..-1]
+ if key == 'hide'
+ conf[2] = bool(conf[2]) unless conf[2].empty?
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ end
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(tk_send_without_enc('pane',
+ win)).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ if key
+ if key == 'hide'
+ conf[2] = bool(conf[2]) unless conf[2].empty?
+ elsif conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if key == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ elsif conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+ alias pane_configinfo paneconfiginfo
+
+ def current_paneconfiginfo(win, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = paneconfiginfo(win, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ paneconfiginfo(win).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ paneconfiginfo(win, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+ alias current_pane_configinfo current_paneconfiginfo
+
+ def panes
+ tk_split_simplelist(tk_send_without_enc('panes')).map{|w|
+ (obj = window(w))? obj: w
+ }
+ end
+
+ def identify(x, y)
+ num_or_nil(tk_send_without_enc('identify', x, y))
+ end
+
+ def sashpos(idx, newpos=None)
+ num_or_str(tk_send_without_enc('sashpos', idx, newpos))
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Panedwindow,
+# :TkPanedwindow, :TkPanedWindow)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tpaned.rb',
+ :Ttk, Tk::Tile::Panedwindow,
+ :TkPanedwindow, :TkPanedWindow)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb
new file mode 100644
index 0000000..0c9d15e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb
@@ -0,0 +1,57 @@
+#
+# tprogressbar widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TProgressbar < TkWindow
+ end
+ Progressbar = TProgressbar
+ end
+end
+
+class Tk::Tile::TProgressbar
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::progressbar'.freeze].freeze
+ else
+ TkCommandNames = ['::tprogressbar'.freeze].freeze
+ end
+ WidgetClassName = 'TProgressbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def step(amount=None)
+ tk_send_without_enc('step', amount).to_f
+ end
+ #def step=(amount)
+ # tk_send_without_enc('step', amount)
+ #end
+
+ def start(interval=None)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 5
+ tk_call_without_enc('::tile::progressbar::start', @path, interval)
+ else
+ tk_send_without_enc('start', interval)
+ end
+ end
+
+ def stop(amount=None)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 5
+ tk_call_without_enc('::tile::progressbar::stop', @path)
+ else
+ tk_send_without_enc('stop', amount)
+ end
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Progressbar, :TkProgressbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tprogressbar.rb',
+ :Ttk, Tk::Tile::Progressbar, :TkProgressbar)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb
new file mode 100644
index 0000000..5dbf260
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb
@@ -0,0 +1,38 @@
+#
+# tradiobutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TRadioButton < Tk::RadioButton
+ end
+ TRadiobutton = TRadioButton
+ RadioButton = TRadioButton
+ Radiobutton = TRadioButton
+ end
+end
+
+class Tk::Tile::TRadioButton < Tk::RadioButton
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::radiobutton'.freeze].freeze
+ else
+ TkCommandNames = ['::tradiobutton'.freeze].freeze
+ end
+ WidgetClassName = 'TRadiobutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Radiobutton,
+# :TkRadiobutton, :TkRadioButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tradiobutton.rb',
+ :Ttk, Tk::Tile::Radiobutton,
+ :TkRadiobutton, :TkRadioButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb
new file mode 100644
index 0000000..85d7831
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb
@@ -0,0 +1,1336 @@
+#
+# treeview widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class Treeview < TkWindow
+ end
+ end
+end
+
+module Tk::Tile::TreeviewConfig
+ include TkItemConfigMethod
+
+ def __item_configinfo_struct(id)
+ # maybe need to override
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>1}
+ end
+ private :__item_configinfo_struct
+
+ def __itemconfiginfo_core(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ return [slot.to_s, tagfontobj(tagid(tagOrId), fontkey)]
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << slot))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ end
+ return [slot, val]
+
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ optval = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ return [slot, val]
+
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return [slot, self.__send__(method, tagOrId)]
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = number(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return [slot, val]
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = num_or_str(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return [slot, val]
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = bool(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return [slot, val]
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return [slot, val]
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val =~ /^[0-9]/
+ return [slot, list(val)]
+ else
+ return [slot, val]
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ return [slot, val]
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.empty?
+ return [slot, nil]
+ else
+ return [slot, TkVarAccess.new(val)]
+ end
+
+ else
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.index('{')
+ return [slot, tk_split_list(val)]
+ else
+ return [slot, tk_tcl2ruby(val)]
+ end
+ end
+
+ else # ! slot
+ ret = Hash[*(tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false))].to_a.collect{|conf|
+ conf[0] = conf[0][1..-1] if conf[0][0] == ?-
+ case conf[0]
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[conf[0]]
+ optval = conf[1]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[1] = val
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = number(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = num_or_str(conf[1])
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = bool(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = simplelist(conf[1])
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1] =~ /^[0-9]/
+ conf[1] = list(conf[1])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1].empty?
+ conf[1] = nil
+ else
+ conf[1] = TkVarAccess.new(conf[1])
+ end
+
+ else
+ if conf[1].index('{')
+ conf[1] = tk_split_list(conf[1])
+ else
+ conf[1] = tk_tcl2ruby(conf[1])
+ end
+ end
+
+ conf
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[1] = tagfontobj(tagid(tagOrId), optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret << [optkey.to_s, self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ return {slot.to_s => tagfontobj(tagid(tagOrId), fontkey)}
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ # On tile-0.7.{2-8}, 'state' option has no '-' at its head.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << slot))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ end
+ return {slot => val}
+
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ optval = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ return {slot => val}
+
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return {slot => self.__send__(method, tagOrId)}
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = number(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return {slot => val}
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = num_or_str(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return {slot => val}
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = bool(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return {slot => val}
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return {slot => val}
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val =~ /^[0-9]/
+ return {slot => list(val)}
+ else
+ return {slot => val}
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ return {slot => val}
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.empty?
+ return {slot => nil}
+ else
+ return {slot => TkVarAccess.new(val)}
+ end
+
+ else
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.index('{')
+ return {slot => tk_split_list(val)}
+ else
+ return {slot => tk_tcl2ruby(val)}
+ end
+ end
+
+ else # ! slot
+ ret = {}
+ ret = Hash[*(tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false))].to_a.collect{|conf|
+ conf[0] = conf[0][1..-1] if conf[0][0] == ?-
+
+ optkey = conf[0]
+ case optkey
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey]
+ optval = conf[1]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[1] = val
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = number(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = num_or_str(conf[1])
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = bool(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = simplelist(conf[1])
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1] =~ /^[0-9]/
+ conf[1] = list(conf[1])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1].empty?
+ conf[1] = nil
+ else
+ conf[1] = TkVarAccess.new(conf[1])
+ end
+
+ else
+ if conf[1].index('{')
+ return [slot, tk_split_list(conf[1])]
+ else
+ return [slot, tk_tcl2ruby(conf[1])]
+ end
+ end
+
+ ret[conf[0]] = conf[1]
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fontconf[1] = tagfontobj(tagid(tagOrId), optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret[optkey.to_s] = self.__send__(method, tagOrId)
+ }
+
+ ret
+ end
+ end
+ end
+ end
+
+ ###################
+
+ def __item_cget_cmd(id)
+ [self.path, *id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, *id]
+ end
+ private :__item_config_cmd
+
+ def __item_numstrval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['width']
+ when :column, 'column'
+ super(id[1]) + ['minwidth']
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ else
+ super(id[1])
+ end
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_strval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ super(id) + ['id']
+ when :column, 'column'
+ super(id[1])
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ else
+ super(id[1])
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_boolval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['open']
+ when :column, 'column'
+ super(id[1]) + ['stretch']
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['values']
+ when :column, 'column'
+ []
+ when :heading, 'heading'
+ []
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_val2ruby_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ {
+ 'tags'=>proc{|arg_id, val|
+ simplelist(val).collect{|tag|
+ Tk::Tile::Treeview::Tag.id2obj(self, tag)
+ }
+ }
+ }
+ when :column, 'column'
+ {}
+ when :heading, 'heading'
+ {}
+ else
+ {}
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def __tile_specific_item_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ []
+ when :column, 'column'
+ []
+ when :heading, 'heading'
+ ['state'] # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ else
+ []
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def itemconfiginfo(tagOrId, slot = nil)
+ __itemconfiginfo_core(tagOrId, slot)
+ end
+
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = __itemconfiginfo_core(tagOrId, slot)
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
+ else
+ ret = {}
+ __itemconfiginfo_core(tagOrId).each{|conf|
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ __itemconfiginfo_core(tagOrId, slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ alias __itemcget_tkstring itemcget_tkstring
+ alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
+ alias __itemconfigure itemconfigure
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+
+ private :__itemcget_tkstring, :__itemcget, :__itemcget_strict
+ private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
+
+ # Treeview Item
+ def itemcget_tkstring(tagOrId, option)
+ __itemcget_tkstring([:item, tagOrId], option)
+ end
+ def itemcget(tagOrId, option)
+ __itemcget([:item, tagOrId], option)
+ end
+ def itemcget_strict(tagOrId, option)
+ __itemcget_strict([:item, tagOrId], option)
+ end
+ def itemconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:item, tagOrId], slot, value)
+ end
+ def itemconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:item, tagOrId], slot)
+ end
+ def current_itemconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:item, tagOrId], slot)
+ end
+
+ # Treeview Column
+ def columncget_tkstring(tagOrId, option)
+ __itemcget_tkstring([:column, tagOrId], option)
+ end
+ def columncget(tagOrId, option)
+ __itemcget([:column, tagOrId], option)
+ end
+ def columncget_strict(tagOrId, option)
+ __itemcget_strict([:column, tagOrId], option)
+ end
+ def columnconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:column, tagOrId], slot, value)
+ end
+ def columnconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:column, tagOrId], slot)
+ end
+ def current_columnconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:column, tagOrId], slot)
+ end
+ alias column_cget_tkstring columncget_tkstring
+ alias column_cget columncget
+ alias column_cget_strict columncget_strict
+ alias column_configure columnconfigure
+ alias column_configinfo columnconfiginfo
+ alias current_column_configinfo current_columnconfiginfo
+
+ # Treeview Heading
+ def headingcget_tkstring(tagOrId, option)
+ if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << option.to_s))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
+ end
+ else
+ __itemcget_tkstring([:heading, tagOrId], option)
+ end
+ end
+ def headingcget_strict(tagOrId, option)
+ if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << option.to_s))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
+ end
+ else
+ __itemcget_strict([:heading, tagOrId], option)
+ end
+ end
+ def headingcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ headingcget_strict(tagOrId, option)
+ else
+ begin
+ headingcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_headingconfiginfo(tagOrId).has_key?(option.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ def headingconfigure(tagOrId, slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ sp_kv = []
+ __tile_specific_item_optkeys([:heading, tagOrId]).each{|k|
+ sp_kv << k << _get_eval_string(slot.delete(k)) if slot.has_key?(k)
+ }
+ tk_call(*(__item_config_cmd([:heading, tagOrId]).concat(sp_kv)))
+ tk_call(*(__item_config_cmd([:heading, tagOrId]).concat(hash_kv(slot))))
+ elsif __tile_specific_item_optkeys([:heading, tagOrId]).index(slot.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << slot.to_s << value))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{slot}" << value))
+ end
+ else
+ __itemconfigure([:heading, tagOrId], slot, value)
+ end
+ self
+ end
+ def headingconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:heading, tagOrId], slot)
+ end
+ def current_headingconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:heading, tagOrId], slot)
+ end
+ alias heading_cget_tkstring headingcget_tkstring
+ alias heading_cget headingcget
+ alias heading_cget_strict headingcget_strict
+ alias heading_configure headingconfigure
+ alias heading_configinfo headingconfiginfo
+ alias current_heading_configinfo current_headingconfiginfo
+
+ # Treeview Tag
+ def tagcget_tkstring(tagOrId, option)
+ __itemcget_tkstring([:tag, :configure, tagOrId], option)
+ end
+ def tagcget(tagOrId, option)
+ __itemcget([:tag, :configure, tagOrId], option)
+ end
+ def tagcget_strict(tagOrId, option)
+ __itemcget_strict([:tag, :configure, tagOrId], option)
+ end
+ def tagconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:tag, :configure, tagOrId], slot, value)
+ end
+ def tagconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:tag, :configure, tagOrId], slot)
+ end
+ def current_tagconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:tag, :configure, tagOrId], slot)
+ end
+ alias tag_cget_tkstring tagcget_tkstring
+ alias tag_cget tagcget
+ alias tag_cget_strict tagcget_strict
+ alias tag_configure tagconfigure
+ alias tag_configinfo tagconfiginfo
+ alias current_tag_configinfo current_tagconfiginfo
+end
+
+########################
+
+class Tk::Tile::Treeview::Item < TkObject
+ ItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
+ (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self.assign(tree, id)
+ tpath = tree.path
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ end
+
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @t = tree
+ @tpath = tpath
+ @path = @id = id
+ }
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
+ }
+ obj
+ end
+
+ def _insert_item(tree, parent_item, idx, keys={})
+ keys = _symbolkey2str(keys)
+ id = keys.delete('id')
+ if id
+ num_or_str(tk_call(tree, 'insert',
+ parent_item, idx, '-id', id, *hash_kv(keys)))
+ else
+ num_or_str(tk_call(tree, 'insert', parent_item, idx, *hash_kv(keys)))
+ end
+ end
+ private :_insert_item
+
+ def initialize(tree, parent_item = '', idx = 'end', keys = {})
+ if parent_item.kind_of?(Hash)
+ keys = parent_item
+ idx = 'end'
+ parent_item = ''
+ elsif idx.kind_of?(Hash)
+ keys = idx
+ idx = 'end'
+ end
+
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = _insert_item(@t, parent_item, idx, keys)
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
+ ItemID_TBL[@tpath][@id] = self
+ }
+ end
+ def id
+ @id
+ end
+
+ def cget_tkstring(option)
+ @t.itemcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.itemcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.itemcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.itemconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_itemconfiginfo(@id, key)
+ end
+
+ def open?
+ cget('open')
+ end
+ def open
+ configure('open', true)
+ self
+ end
+ def close
+ configure('open', false)
+ self
+ end
+
+ def tag_has?(tag)
+ @t.tag_has?(tag, @id)
+ end
+ alias has_tag? tag_has?
+
+ def bbox(column=None)
+ @t.bbox(@id, column)
+ end
+
+ def children
+ @t.children(@id)
+ end
+ def set_children(*items)
+ @t.set_children(@id, *items)
+ self
+ end
+
+ def delete
+ @t.delete(@id)
+ self
+ end
+
+ def detach
+ @t.detach(@id)
+ self
+ end
+
+ def exist?
+ @t.exist?(@id)
+ end
+
+ def focus
+ @t.focus_item(@id)
+ end
+
+ def index
+ @t.index(@id)
+ end
+
+ def insert(idx='end', keys={})
+ @t.insert(@id, idx, keys)
+ end
+
+ def move(parent, idx)
+ @t.move(@id, parent, idx)
+ self
+ end
+
+ def next_item
+ @t.next_item(@id)
+ end
+
+ def parent_item
+ @t.parent_item(@id)
+ end
+
+ def prev_item
+ @t.prev_item(@id)
+ end
+
+ def see
+ @t.see(@id)
+ self
+ end
+
+ def selection_add
+ @t.selection_add(@id)
+ self
+ end
+
+ def selection_remove
+ @t.selection_remove(@id)
+ self
+ end
+
+ def selection_set
+ @t.selection_set(@id)
+ self
+ end
+
+ def selection_toggle
+ @t.selection_toggle(@id)
+ self
+ end
+
+ def get_directory
+ @t.get_directory(@id)
+ end
+ alias get_dictionary get_directory
+
+ def get(col)
+ @t.get(@id, col)
+ end
+
+ def set(col, value)
+ @t.set(@id, col, value)
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview::Root < Tk::Tile::Treeview::Item
+ def self.new(tree, keys = {})
+ tpath = tree.path
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ obj = Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ else
+ #super(tree, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
+ end
+
+ def initialize(tree, keys = {})
+ # dummy:: not called by 'new' method
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview::Tag < TkObject
+ include TkTreatTagFont
+
+ TagID_TBL = TkCore::INTERP.create_table
+
+ (Tag_ID = ['tile_treeview_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::TagID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
+ (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(tree, keys=nil)
+ @parent = @t = tree
+ @tpath = tree.path
+ Tag_ID.mutex.synchronize{
+ @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
+ Tag_ID[1].succ!
+ }
+ TagID_TBL.mutex.synchronize{
+ TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
+ TagID_TBL[@tpath][@id] = self
+ }
+ if keys && keys != None
+ tk_call_without_enc(@tpath, 'tag', 'configure', @id, *hash_kv(keys,true))
+ end
+ end
+ def id
+ @id
+ end
+
+ def tag_has?(item)
+ @t.tag_has?(@id, item)
+ end
+ alias added? tag_has?
+
+ def tag_has
+ @t.tag_has(@id)
+ end
+
+ def add(*items)
+ @t.tag_add(@id, *items)
+ end
+
+ def remove(*items)
+ @t.tag_remove(@id, *items)
+ end
+
+ def bind(seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tag_bind(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_append(seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tag_bind_append(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_remove(seq)
+ @t.tag_bind_remove(@id, seq)
+ self
+ end
+
+ def bindinfo(seq=nil)
+ @t.tag_bindinfo(@id, seq)
+ end
+
+ def cget_tkstring(option)
+ @t.tagcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.tagcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.tagcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.tagconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.tagconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_tagconfiginfo(@id, key)
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview < TkWindow
+ include Tk::Tile::TileWidget
+ include Scrollable
+
+ include Tk::Tile::TreeviewConfig
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::treeview'.freeze].freeze
+ else
+ TkCommandNames = ['::treeview'.freeze].freeze
+ end
+ WidgetClassName = 'Treeview'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
+ }
+ Tk::Tile::Treeview::Tag::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ }
+ end
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def tagid(id)
+ if id.kind_of?(Tk::Tile::Treeview::Item) ||
+ id.kind_of?(Tk::Tile::Treeview::Tag)
+ id.id
+ elsif id.kind_of?(Array)
+ # size is 2 or 3
+ id[0..-2] << _get_eval_string(id[-1])
+ else
+ _get_eval_string(id)
+ end
+ end
+
+ def root
+ Tk::Tile::Treeview::Root.new(self)
+ end
+
+ def bbox(item, column=None)
+ list(tk_send('item', 'bbox', item, column))
+ end
+
+ def children(item)
+ simplelist(tk_send_without_enc('children', item)).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
+ end
+ def set_children(item, *items)
+ tk_send_without_enc('children', item,
+ array2tk_list(items.flatten, true))
+ self
+ end
+
+ def delete(*items)
+ tk_send_without_enc('delete', array2tk_list(items.flatten, true))
+ self
+ end
+
+ def detach(*items)
+ tk_send_without_enc('detach', array2tk_list(items.flatten, true))
+ self
+ end
+
+ def exist?(item)
+ bool(tk_send_without_enc('exists', _get_eval_enc_str(item)))
+ end
+
+ def focus_item(item = nil)
+ if item
+ tk_send('focus', item)
+ item
+ else
+ id = tk_send('focus')
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+ end
+
+ def identify(x, y)
+ # tile-0.7.2 or previous
+ ret = simplelist(tk_send('identify', x, y))
+ case ret[0]
+ when 'heading', 'separator'
+ ret[-1] = num_or_str(ret[-1])
+ when 'cell'
+ ret[1] = Tk::Tile::Treeview::Item.id2obj(self, ret[1])
+ ret[-1] = num_or_str(ret[-1])
+ when 'item', 'row'
+ ret[1] = Tk::Tile::Treeview::Item.id2obj(self, ret[1])
+ end
+ end
+
+ def identify_region(x, y)
+ tk_send('identify', 'region', x, y)
+ end
+
+ def identify_item(x, y)
+ id = tk_send('identify', 'item', x, y)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+
+ def identify_element(x, y)
+ tk_send('identify', 'element', x, y)
+ end
+
+ def row_identify(x, y)
+ id = tk_send('identify', 'row', x, y)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+ alias identify_row row_identify
+
+ def column_identify(x, y)
+ tk_send('identify', 'column', x, y)
+ end
+ alias identify_column column_identify
+
+ def index(item)
+ number(tk_send('index', item))
+ end
+
+ # def insert(parent, idx='end', keys={})
+ # keys = _symbolkey2str(keys)
+ # id = keys.delete('id')
+ # if id
+ # num_or_str(tk_send('insert', parent, idx, '-id', id, *hash_kv(keys)))
+ # else
+ # num_or_str(tk_send('insert', parent, idx, *hash_kv(keys)))
+ # end
+ # end
+ def insert(parent, idx='end', keys={})
+ Tk::Tile::Treeview::Item.new(self, parent, idx, keys)
+ end
+
+ # def instate(spec, cmd=Proc.new)
+ # tk_send('instate', spec, cmd)
+ # end
+ # def state(spec=None)
+ # tk_send('state', spec)
+ # end
+
+ def move(item, parent, idx)
+ tk_send('move', item, parent, idx)
+ self
+ end
+
+ def next_item(item)
+ id = tk_send('next', item)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+
+ def parent_item(item)
+ if (id = tk_send('parent', item)).empty?
+ Tk::Tile::Treeview::Root.new(self)
+ else
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+ end
+
+ def prev_item(item)
+ id = tk_send('prev', item)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+
+ def see(item)
+ tk_send('see', item)
+ self
+ end
+
+ def selection
+ simplelist(tk_send('selection')).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
+ end
+ alias selection_get selection
+
+ def selection_add(*items)
+ tk_send('selection', 'add', array2tk_list(items.flatten, true))
+ self
+ end
+ def selection_remove(*items)
+ tk_send('selection', 'remove', array2tk_list(items.flatten, true))
+ self
+ end
+ def selection_set(*items)
+ tk_send('selection', 'set', array2tk_list(items.flatten, true))
+ self
+ end
+ def selection_toggle(*items)
+ tk_send('selection', 'toggle', array2tk_list(items.flatten, true))
+ self
+ end
+
+ def get_directory(item)
+ # tile-0.7+
+ ret = []
+ lst = simplelist(tk_send('set', item))
+ until lst.empty?
+ col = lst.shift
+ val = lst.shift
+ ret << [col, val]
+ end
+ ret
+ end
+ alias get_dictionary get_directory
+
+ def get(item, col)
+ tk_send('set', item, col)
+ end
+ def set(item, col, value)
+ tk_send('set', item, col, value)
+ self
+ end
+
+ def tag_has?(tag, item)
+ bool(tk_send('tag', 'has', tagid(tag), tagid(item)))
+ end
+ def tag_has(tag)
+ tk_split_simplelist(tk_send('tag', 'has', tagid(tag))).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
+ end
+
+ def tag_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+ alias tagbind tag_bind
+
+ def tag_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+ alias tagbind_append tag_bind_append
+
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'tag', 'bind', tag], seq)
+ self
+ end
+ alias tagbind_remove tag_bind_remove
+
+ def tag_bindinfo(tag, context=nil)
+ _bindinfo([@path, 'tag', 'bind', tag], context)
+ end
+ alias tagbindinfo tag_bindinfo
+
+ def tag_names
+ tk_split_simplelist(tk_send('tag', 'names')).collect{|id|
+ Tk::Tile::Treeview::Tag.id2obj(self, id)
+ }
+ end
+
+ def tag_add(tag, *items)
+ fail ArgumentError, "no target items" if items.empty?
+ tk_send('tag', 'add', tagid(tag), *(items.collect{|item| tagid(item)}))
+ self
+ end
+
+ def tag_remove(tag, *items)
+ tk_send('tag', 'remove', tagid(tag), *(items.collect{|item| tagid(item)}))
+ self
+ end
+
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Treeview, :TkTreeview)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/treeview.rb',
+ :Ttk, Tk::Tile::Treeview, :TkTreeview)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb
new file mode 100644
index 0000000..7eefcef
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb
@@ -0,0 +1,56 @@
+#
+# tscale & tprogress widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TScale < Tk::Scale
+ end
+ Scale = TScale
+
+ class TProgress < TScale
+ end
+ Progress = TProgress
+ end
+end
+
+class Tk::Tile::TScale < Tk::Scale
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::scale'.freeze].freeze
+ else
+ TkCommandNames = ['::tscale'.freeze].freeze
+ end
+ WidgetClassName = 'TScale'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ alias identify ttk_identify
+end
+
+class Tk::Tile::TProgress < Tk::Tile::TScale
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::progress'.freeze].freeze
+ else
+ TkCommandNames = ['::tprogress'.freeze].freeze
+ end
+ WidgetClassName = 'TProgress'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scale, :TkScale)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscale.rb',
+ :Ttk, Tk::Tile::Scale, :TkScale)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb
new file mode 100644
index 0000000..c6bba58
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb
@@ -0,0 +1,63 @@
+#
+# tscrollbar widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TScrollbar < Tk::Scrollbar
+ end
+ Scrollbar = TScrollbar
+ end
+end
+
+class Tk::Tile::TScrollbar < Tk::Scrollbar
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::scrollbar'.freeze].freeze
+ else
+ TkCommandNames = ['::tscrollbar'.freeze].freeze
+ end
+ WidgetClassName = 'TScrollbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ alias identify ttk_identify
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scrollbar, :TkScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscrollbar.rb',
+ :Ttk, Tk::Tile::Scrollbar, :TkScrollbar)
+
+#######################################################################
+
+class Tk::Tile::XScrollbar < Tk::Tile::TScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'horizontal'
+ super(keys)
+ end
+ private :create_self
+end
+
+class Tk::Tile::YScrollbar < Tk::Tile::TScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'vertical'
+ super(keys)
+ end
+ private :create_self
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::XScrollbar, :TkXScrollbar)
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::YScrollbar, :TkYScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscrollbar.rb',
+ :Ttk, Tk::Tile::XScrollbar, :TkXScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscrollbar.rb',
+ :Ttk, Tk::Tile::YScrollbar, :TkYScrollbar)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb
new file mode 100644
index 0000000..ffd2f6f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb
@@ -0,0 +1,34 @@
+#
+# tseparator widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TSeparator < TkWindow
+ end
+ Separator = TSeparator
+ end
+end
+
+class Tk::Tile::TSeparator < TkWindow
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::separator'.freeze].freeze
+ else
+ TkCommandNames = ['::tseparator'.freeze].freeze
+ end
+ WidgetClassName = 'TSeparator'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Separator, :TkSeparator)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tseparator.rb',
+ :Ttk, Tk::Tile::Separator, :TkSeparator)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb
new file mode 100644
index 0000000..2f2d73c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb
@@ -0,0 +1,107 @@
+#
+# ttk::spinbox widget (Tcl/Tk 8.6b1 or later)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TSpinbox < Tk::Tile::TEntry
+ end
+ Spinbox = TSpinbox
+ end
+end
+
+class Tk::Tile::TSpinbox < Tk::Tile::TEntry
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::spinbox'.freeze].freeze
+ else
+ TkCommandNames = ['::tspinbox'.freeze].freeze
+ end
+ WidgetClassName = 'TSpinbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class SpinCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?d, ?s, :direction ],
+ [ ?s, ?e, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ #enc = Tk.encoding
+ enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
+ if enc
+ Tk.fromUTF8(TkComm::string(val), enc)
+ else
+ TkComm::string(val)
+ end
+ }
+ ],
+
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ (val)? '1': '0'
+ end
+ end
+
+ def self._config_keys
+ ['command']
+ end
+ end
+
+ def __validation_class_list
+ super() << SpinCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, SpinCommand)
+
+ def __boolval_optkeys
+ super() << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'buttonbackground' << 'format'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def current
+ number(tk_send_without_enc('current'))
+ end
+ def current=(idx)
+ tk_send('current', idx)
+ end
+
+ def set(val)
+ tk_send('set', val)
+ end
+
+ alias identify ttk_identify
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Spinbox, :TkSpinbox)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tspinbox.rb',
+ :Ttk, Tk::Tile::Spinbox, :TkSpinbox)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb
new file mode 100644
index 0000000..a81cd7b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb
@@ -0,0 +1,30 @@
+#
+# tsquare widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TSquare < TkWindow
+ end
+ Square = TSquare
+ end
+end
+
+class Tk::Tile::TSquare < TkWindow
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::square'.freeze].freeze
+ else
+ TkCommandNames = ['::tsquare'.freeze].freeze
+ end
+ WidgetClassName = 'TSquare'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND.rb
new file mode 100644
index 0000000..5d52e34
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND.rb
@@ -0,0 +1,18 @@
+#
+# TkDND (Tk Drag & Drop Extension) support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+module Tk
+ module TkDND
+ autoload :DND, 'tkextlib/tkDND/tkdnd'
+ autoload :Shape, 'tkextlib/tkDND/shape'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb
new file mode 100644
index 0000000..d44068e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb
@@ -0,0 +1,125 @@
+#
+# tkextlib/tkDND/shape.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+# TkPackage.require('Shape', '0.3')
+TkPackage.require('Shape')
+
+module Tk
+ module TkDND
+ module Shape
+ extend TkCore
+
+ PACKAGE_NAME = 'Shape'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+=begin
+ def self.package_version
+ begin
+ TkPackage.require('Shape')
+ rescue
+ ''
+ end
+ end
+=end
+ class << self
+ def package_version
+ Tk.tk_call('set', 'shape_version')
+ end
+ alias shape_version package_version
+
+ def package_patchlevel
+ Tk.tk_call('set', 'shape_patchLevel')
+ end
+ alias shape_patchlevel package_patchlevel
+
+ def version
+ tk_call('shape', 'version')
+ end
+ alias xshape_version version
+ end
+
+ ############################
+
+ def shape_bounds(kind=nil)
+ if kind
+ ret = tk_call('shape', 'bounds', @path, "-#{kind}")
+ else
+ ret = tk_call('shape', 'bounds', @path)
+ end
+ if ret == ""
+ nil
+ else
+ list(ret)
+ end
+ end
+
+ def shape_get(kind=nil)
+ if kind
+ list(tk_call('shape', 'get', @path, "-#{kind}"))
+ else
+ list(tk_call('shape', 'get', @path))
+ end
+ end
+
+ def shape_offset(x, y, kind=nil)
+ if kind
+ tk_call('shape', 'get', @path, "-#{kind}", x, y)
+ else
+ tk_call('shape', 'get', @path, x, y)
+ end
+ self
+ end
+
+ def _parse_shapespec_param(args)
+ cmd = []
+
+ kind_keys = ['bounding', 'clip', 'both']
+ offset_keys = ['offset']
+ srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window']
+
+ cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s)
+
+ if offset_keys.member?(args[0].to_s)
+ cmd << "-#{args.shift}"
+ cmd << args.shift # xOffset
+ cmd << args.shift # yOffset
+ end
+
+ if srckind_keys.member?(args[0].to_s)
+ cmd << "-#{args.shift}"
+ end
+
+ cmd.concat(args)
+
+ cmd
+ end
+ private :_parse_shapespec_param
+
+ def shape_set(*args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
+ tk_call('shape', 'set', @path, *(_parse_shapespec_param(args)))
+ self
+ end
+
+ def shape_update(op, *args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
+ tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args)))
+ self
+ end
+ end
+ end
+end
+
+class TkWindow
+ include Tk::TkDND::Shape
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
new file mode 100644
index 0000000..38e05ce
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
@@ -0,0 +1,182 @@
+#
+# tkextlib/tkDND/tkdnd.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+TkPackage.require('tkdnd')
+
+module Tk
+ module TkDND
+ PACKAGE_NAME = 'tkdnd'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tkdnd')
+ rescue
+ ''
+ end
+ end
+
+ class DND_Subst < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?a, ?l, :actions ],
+ [ ?A, ?s, :action ],
+ [ ?b, ?L, :codes ],
+ [ ?c, ?s, :code ],
+ [ ?d, ?l, :descriptions ],
+ [ ?D, ?l, :data ],
+ [ ?L, ?l, :source_types ],
+ [ ?m, ?l, :modifiers ],
+ [ ?t, ?l, :types ],
+ [ ?T, ?s, :type ],
+ [ ?W, ?w, :widget ],
+ [ ?x, ?n, :x ],
+ [ ?X, ?n, :x_root ],
+ [ ?y, ?n, :y ],
+ [ ?Y, ?n, :y_root ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?l, TkComm.method(:list) ],
+ [ ?L, TkComm.method(:simplelist) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ # setup tables
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ module DND
+ def self.version
+ begin
+ TkPackage.require('tkdnd')
+ rescue
+ ''
+ end
+ end
+
+ def dnd_bindtarget_info(type=nil, event=nil)
+ if event
+ procedure(tk_call('dnd', 'bindtarget', @path, type, event))
+ elsif type
+ procedure(tk_call('dnd', 'bindtarget', @path, type))
+ else
+ simplelist(tk_call('dnd', 'bindtarget', @path))
+ end
+ end
+
+ #def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args)
+ # event = tk_event_sequence(event)
+ # if prior.kind_of?(Numeric)
+ # tk_call('dnd', 'bindtarget', @path, type, event,
+ # install_bind_for_event_class(DND_Subst, cmd, *args),
+ # prior)
+ # else
+ # tk_call('dnd', 'bindtarget', @path, type, event,
+ # install_bind_for_event_class(DND_Subst, cmd, prior, *args))
+ # end
+ # self
+ #end
+ def dnd_bindtarget(type, event, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+
+ prior = 50
+ prior = args.shift unless args.empty?
+
+ event = tk_event_sequence(event)
+ if prior.kind_of?(Numeric)
+ tk_call('dnd', 'bindtarget', @path, type, event,
+ install_bind_for_event_class(DND_Subst, cmd, *args),
+ prior)
+ else
+ tk_call('dnd', 'bindtarget', @path, type, event,
+ install_bind_for_event_class(DND_Subst, cmd, prior, *args))
+ end
+ self
+ end
+
+ def dnd_cleartarget
+ tk_call('dnd', 'cleartarget', @path)
+ self
+ end
+
+ def dnd_bindsource_info(type=nil)
+ if type
+ procedure(tk_call('dnd', 'bindsource', @path, type))
+ else
+ simplelist(tk_call('dnd', 'bindsource', @path))
+ end
+ end
+
+ #def dnd_bindsource(type, cmd=Proc.new, prior=None)
+ # tk_call('dnd', 'bindsource', @path, type, cmd, prior)
+ # self
+ #end
+ def dnd_bindsource(type, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+
+ args = [TkComm::None] if args.empty?
+
+ tk_call('dnd', 'bindsource', @path, type, cmd, *args)
+ self
+ end
+
+ def dnd_clearsource()
+ tk_call('dnd', 'clearsource', @path)
+ self
+ end
+
+ def dnd_drag(keys=nil)
+ tk_call('dnd', 'drag', @path, *hash_kv(keys))
+ self
+ end
+ end
+ end
+end
+
+class TkWindow
+ include Tk::TkDND::DND
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb b/jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb
new file mode 100644
index 0000000..5fddde7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb
@@ -0,0 +1,13 @@
+#
+# TkHtml support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkHTML/setup.rb'
+
+# load library
+require 'tkextlib/tkHTML/htmlwidget'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
new file mode 100644
index 0000000..b9ee90a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
@@ -0,0 +1,453 @@
+#
+# tkextlib/tkHTML/htmlwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkHTML/setup.rb'
+
+# TkPackage.require('Tkhtml', '2.0')
+TkPackage.require('Tkhtml')
+
+module Tk
+ class HTML_Widget < TkWindow
+ PACKAGE_NAME = 'Tkhtml'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Tkhtml')
+ rescue
+ ''
+ end
+ end
+
+ class ClippingWindow < TkWindow
+ end
+ end
+end
+
+class Tk::HTML_Widget::ClippingWindow
+ WidgetClassName = 'HtmlClip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ HtmlClip_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ HtmlClip_TBL.mutex.synchronize{ HtmlClip_TBL.clear }
+ }
+
+ def self.new(parent, keys={})
+ if parent.kind_of?(Hash)
+ keys = TkComm._symbolkey2str(parent)
+ parent = keys.delete('parent')
+ end
+
+ if parent.kind_of?(String)
+ ppath = parent.path
+ elsif parent
+ ppath = parent
+ else
+ ppath = ''
+ end
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+ }
+
+ widgetname = keys.delete('widgetname')
+ if widgetname =~ /^(.*)\.[^.]+$/
+ ppath2 = $1
+ if ppath2[0] != ?.
+ ppath2 = ppath + '.' + ppath2
+ end
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+ }
+
+ ppath = ppath2
+ end
+
+ parent = TkComm._genobj_for_tkwidget(ppath)
+ unless parent.kind_of?(Tk::HTML_Widget)
+ fail ArgumentError, "parent must be a Tk::HTML_Widget instance"
+ end
+
+ super(parent)
+ end
+
+ def initialize(parent)
+ @parent = parent
+ @ppath = parent.path
+ @path = @id = @ppath + '.x'
+ HtmlClip_TBL.mutex.synchronize{
+ HtmlClip_TBL[@ppath] = self
+ }
+ end
+
+ def method_missing(m, *args, &b)
+ @parent.__send__(m, *args, &b)
+ end
+end
+
+class Tk::HTML_Widget
+ include Scrollable
+
+ TkCommandNames = ['html'.freeze].freeze
+ WidgetClassName = 'Html'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'base' << 'selectioncolor' << 'unvisitedcolor' << 'visitedcolor'
+ end
+ private :__strval_optkeys
+
+ ###################################
+ # class methods
+ ###################################
+ def self.reformat(src, dst, txt)
+ tk_call('html', 'reformat', src, dst, txt)
+ end
+
+ def self.url_join(*args) # args := sheme authority path query fragment
+ tk_call('html', 'urljoin', *args)
+ end
+
+ def self.url_split(uri)
+ tk_call('html', 'urlsplit', uri)
+ end
+
+ def self.lockcopy(src, dst)
+ tk_call('html', 'lockcopy', src, dst)
+ end
+
+ def self.gzip_file(file, dat)
+ tk_call('html', 'gzip', 'file', file, dat)
+ end
+
+ def self.gunzip_file(file, dat)
+ tk_call('html', 'gunzip', 'file', filet)
+ end
+
+ def self.gzip_data(dat)
+ tk_call('html', 'gzip', 'data', file, dat)
+ end
+
+ def self.gunzip_data(dat)
+ tk_call('html', 'gunzip', 'data', filet)
+ end
+
+ def self.base64_encode(dat)
+ tk_call('html', 'base64', 'encode', dat)
+ end
+
+ def self.base64_decode(dat)
+ tk_call('html', 'base64', 'encode', dat)
+ end
+
+ def self.text_format(dat, len)
+ tk_call('html', 'text', 'format', dat, len)
+ end
+
+ def self.xor(cmd, *args)
+ tk_call('html', 'xor', cmd, *args)
+ end
+
+ def self.stdchan(cmd, channel)
+ tk_call('html', 'stdchan', cmd, channel)
+ end
+
+ def self.crc32(data)
+ tk_call('html', 'crc32', data)
+ end
+
+ ###################################
+ # instance methods
+ ###################################
+ def clipping_window
+ ClippingWindow.new(self)
+ end
+ alias clipwin clipping_window
+ alias htmlclip clipping_window
+
+ def bgimage(image, tid=None)
+ tk_send('bgimage', image, tid)
+ self
+ end
+
+ def clear()
+ tk_send('clear')
+ self
+ end
+
+ def coords(index=None, percent=None)
+ tk_send('coords', index, percent)
+ end
+
+ def forminfo(*args)
+ tk_send('forminfo', *args)
+ end
+ alias form_info forminfo
+
+ def href(x, y)
+ simplelist(tk_send('href', x, y))
+ end
+
+ def image_add(id, img)
+ tk_send('imageadd', id, img)
+ self
+ end
+
+ def image_at(x, y)
+ tk_send('imageat', x, y)
+ end
+
+ def images()
+ list(tk_send('images'))
+ end
+
+ def image_set(id, num)
+ tk_send('imageset', id, num)
+ self
+ end
+
+ def image_update(id, imgs)
+ tk_send('imageupdate', id, imgs)
+ self
+ end
+
+ def index(idx, count=None, unit=None)
+ tk_send('index', idx, count, unit)
+ end
+
+ def insert_cursor(idx)
+ tk_send('insert', idx)
+ end
+
+ def names()
+ simple_list(tk_send('names'))
+ end
+
+ def on_screen(id, x, y)
+ bool(tk_send('onscreen', id, x, y))
+ end
+
+ def over(x, y)
+ list(tk_send('over', x, y))
+ end
+
+ def over_markup(x, y)
+ list(tk_send('over', x, y, '-muponly'))
+ end
+
+ def over_attr(x, y, attrs)
+ list(tk_send('overattr', x, y, attrs))
+ end
+
+ def parse(txt)
+ tk_send('parse', txt)
+ self
+ end
+
+ def resolver(*uri_args)
+ tk_send('resolver', *uri_args)
+ end
+
+ def selection_clear()
+ tk_send('selection', 'clear')
+ self
+ end
+
+ def selection_set(first, last)
+ tk_send('selection', 'set', first, last)
+ self
+ end
+
+ def refresh(*opts)
+ tk_send('refresh', *opts)
+ end
+
+ def layout()
+ tk_send('layout')
+ end
+
+ def sizewindow(*args)
+ tk_send('sizewindow', *args)
+ end
+
+ def postscript(*args)
+ tk_send('postscript', *args)
+ end
+
+ def source()
+ tk_send('source')
+ end
+
+ def plain_text(first, last)
+ tk_send('text', 'ascii', first, last)
+ end
+ alias ascii_text plain_text
+ alias text_ascii plain_text
+
+ def text_delete(first, last)
+ tk_send('text', 'delete', first, last)
+ self
+ end
+
+ def html_text(first, last)
+ tk_send('text', 'html', first, last)
+ end
+ alias text_html html_text
+
+ def text_insert(idx, txt)
+ tk_send('text', 'insert', idx, txt)
+ self
+ end
+
+ def break_text(idx)
+ tk_send('text', 'break', idx)
+ end
+ alias text_break break_text
+
+ def text_find(txt, *args)
+ tk_send('text', 'find', txt, *args)
+ end
+
+ def text_table(idx, imgs=None, attrs=None)
+ tk_send('text', 'table', idx, imgs, attrs)
+ end
+
+ def token_append(tag, *args)
+ tk_send('token', 'append', tag, *args)
+ self
+ end
+
+ def token_delete(first, last=None)
+ tk_send('token', 'delete', first, last)
+ self
+ end
+
+ def token_define(*args)
+ tk_send('token', 'defile', *args)
+ self
+ end
+
+ def token_find(tag, *args)
+ list(tk_send('token', 'find', tag, *args))
+ end
+
+ def token_get(first, last=None)
+ list(tk_send('token', 'get', first, last))
+ end
+
+ def token_list(first, last=None)
+ list(tk_send('token', 'list', first, last))
+ end
+
+ def token_markup(first, last=None)
+ list(tk_send('token', 'markup', first, last))
+ end
+
+ def token_DOM(first, last=None)
+ list(tk_send('token', 'domtokens', first, last))
+ end
+ alias token_dom token_DOM
+ alias token_domtokens token_DOM
+ alias token_dom_tokens token_DOM
+
+ def token_get_end(idx)
+ tk_send('token', 'getend', idx)
+ end
+ alias token_getend token_get_end
+
+ def token_offset(start, num1, num2)
+ list(tk_send('token', 'offset', start, num1, num2))
+ end
+
+ def token_get_attr(idx, name=None)
+ list(tk_send('token', 'attr', idx, name))
+ end
+
+ def token_set_attr(idx, name=None, val=None)
+ tk_send('token', 'attr', idx, name, val)
+ self
+ end
+
+ def token_handler(tag, cmd=nil, &b)
+ cmd = Proc.new(&b) if !cmd && b
+ if cmd
+ tk_send('token', 'handler', tag, cmd)
+ return self
+ else
+ return tk_send('token', 'handler', tag)
+ end
+ end
+
+ def token_insert(idx, tag, *args)
+ tk_send('token', 'insert', idx, tag, *args)
+ self
+ end
+
+ def token_attrs(*args)
+ list(tk_send('token', 'attrs', *args))
+ end
+
+ def token_unique(*args)
+ list(tk_send('token', 'unique', *args))
+ end
+
+ def token_on_events(*args)
+ list(tk_send('token', 'onEvents', *args))
+ end
+
+ def dom_nameidx(tag, name)
+ number(tk_send('dom', 'nameidx', tag, name))
+ end
+ alias dom_name_index dom_nameidx
+
+ def dom_radioidx(tag, name)
+ number(tk_send('dom', 'radioidx', tag, name))
+ end
+ alias dom_radio_index dom_radioidx
+
+ def dom_id(*spec)
+ tk_send('dom', 'id', *spec)
+ end
+
+ def dom_ids(*spec)
+ list(tk_send('dom', 'ids', *spec))
+ end
+
+ def dom_value(*spec)
+ list(tk_send('dom', 'value', *spec))
+ end
+
+ def dom_attr(idx)
+ tk_send('dom', 'attr', idx)
+ end
+
+ def dom_formel(name)
+ tk_send('dom', 'formel', name)
+ end
+ alias dom_form_element dom_formel
+
+ def dom_tree(idx, val)
+ list(tk_send('dom', 'tree', idx, val))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg.rb
new file mode 100644
index 0000000..c01359d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg.rb
@@ -0,0 +1,36 @@
+#
+# TkImg extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('Img', '1.3')
+TkPackage.require('Img')
+
+module Tk
+ module Img
+ PACKAGE_NAME = 'Img'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Img')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+# autoload
+autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/README b/jni/ruby/ext/tk/lib/tkextlib/tkimg/README
new file mode 100644
index 0000000..f5981cb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/README
@@ -0,0 +1,26 @@
+
+ [ Tcl/Tk Image formats (TkImg) support ]
+
+TkImg contains a collection of format handlers for the Tk photo
+image type, and a new image type, pixmaps.
+
+Supported formats of TkImg version 1.3 are
+-------------------------------------------------------
+ bmp : Windows Bitmap Format
+ gif : Graphics Interchange Format
+ ico : Windows Icon Format
+ jpeg : Joint Picture Expert Group format
+ pcx : Paintbrush Format
+ pixmap : Pixmap Image type
+ png : Portable Network Graphics format
+ ppm : Portable Pixmap format
+ ps : Adobe PostScript Format
+ sgi : SGI Native Format
+ sun : Sun Raster Format
+ tga : Truevision Targa Format
+ tiff : Tagged Image File Format
+ window : Tk Windows
+ xbm : X Window Bitmap Format
+ xpm : X Window Pixmap Format
+-------------------------------------------------------
+
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb
new file mode 100644
index 0000000..ea90181
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'bmp'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+#TkPackage.require('img::bmp', '1.3')
+TkPackage.require('img::bmp')
+
+module Tk
+ module Img
+ module BMP
+ PACKAGE_NAME = 'img::bmp'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::bmp')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb
new file mode 100644
index 0000000..cae8336
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'DTED'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::dted', '1.4')
+TkPackage.require('img::dted')
+
+module Tk
+ module Img
+ module DTED
+ PACKAGE_NAME = 'img::dted'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::dted')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb
new file mode 100644
index 0000000..d542d47
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'gif'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::gif', '1.3')
+TkPackage.require('img::gif')
+
+module Tk
+ module Img
+ module GIF
+ PACKAGE_NAME = 'img::gif'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::gif')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb
new file mode 100644
index 0000000..e79bdf4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'ico'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ico', '1.3')
+TkPackage.require('img::ico')
+
+module Tk
+ module Img
+ module ICO
+ PACKAGE_NAME = 'img::ico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb
new file mode 100644
index 0000000..2126120
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'jpeg'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::jpeg', '1.3')
+TkPackage.require('img::jpeg')
+
+module Tk
+ module Img
+ module JPEG
+ PACKAGE_NAME = 'img::jpeg'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::jpeg')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb
new file mode 100644
index 0000000..6831f4d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'pcx'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::pcx', '1.3')
+TkPackage.require('img::pcx')
+
+module Tk
+ module Img
+ module PCX
+ PACKAGE_NAME = 'img::pcx'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::pcx')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb
new file mode 100644
index 0000000..bd1b870
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb
@@ -0,0 +1,44 @@
+#
+# TkImg - format 'pixmap'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::pixmap', '1.3')
+TkPackage.require('img::pixmap')
+
+module Tk
+ module Img
+ module PIXMAP
+ PACKAGE_NAME = 'img::pixmap'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::pixmap')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class TkPixmapImage<TkImage
+ def self.version
+ Tk::Img::PIXMAP.version
+ end
+
+ def initialize(*args)
+ @type = 'pixmap'
+ super(*args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb
new file mode 100644
index 0000000..5c829f4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'png'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::png', '1.3')
+TkPackage.require('img::png')
+
+module Tk
+ module Img
+ module PNG
+ PACKAGE_NAME = 'img::png'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::png')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb
new file mode 100644
index 0000000..eacfae4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'ppm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ppm', '1.3')
+TkPackage.require('img::ppm')
+
+module Tk
+ module Img
+ module PPM
+ PACKAGE_NAME = 'img::ppm'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::ppm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb
new file mode 100644
index 0000000..68e9178
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'ps'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ps', '1.3')
+TkPackage.require('img::ps')
+
+module Tk
+ module Img
+ module PS
+ PACKAGE_NAME = 'img::ps'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::ps')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb
new file mode 100644
index 0000000..5f1cdca
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'Raw Data'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::raw', '1.4')
+TkPackage.require('img::raw')
+
+module Tk
+ module Img
+ module Raw
+ PACKAGE_NAME = 'img::raw'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::raw')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb
new file mode 100644
index 0000000..ec7038b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'sgi'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::sgi', '1.3')
+TkPackage.require('img::sgi')
+
+module Tk
+ module Img
+ module SGI
+ PACKAGE_NAME = 'img::sgi'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::sgi')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb
new file mode 100644
index 0000000..651f946
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'sun'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::sun', '1.3')
+TkPackage.require('img::sun')
+
+module Tk
+ module Img
+ module SUN
+ PACKAGE_NAME = 'img::sun'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::sun')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb
new file mode 100644
index 0000000..1eae407
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'tga'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::tga', '1.3')
+TkPackage.require('img::tga')
+
+module Tk
+ module Img
+ module TGA
+ PACKAGE_NAME = 'img::tga'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::tga')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb
new file mode 100644
index 0000000..ed271c2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'tiff'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::tiff', '1.3')
+TkPackage.require('img::tiff')
+
+module Tk
+ module Img
+ module TIFF
+ PACKAGE_NAME = 'img::tiff'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::tiff')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb
new file mode 100644
index 0000000..3b5906f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'window'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::window', '1.3')
+TkPackage.require('img::window')
+
+module Tk
+ module Img
+ module WINDOW
+ PACKAGE_NAME = 'img::window'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::window')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb
new file mode 100644
index 0000000..f4bea03
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'xbm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::xbm', '1.3')
+TkPackage.require('img::xbm')
+
+module Tk
+ module Img
+ module XBM
+ PACKAGE_NAME = 'img::xbm'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::xbm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb
new file mode 100644
index 0000000..5119c87
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'xpm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::xpm', '1.3')
+TkPackage.require('img::xpm')
+
+module Tk
+ module Img
+ module XPM
+ PACKAGE_NAME = 'img::xpm'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::xpm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktable.rb b/jni/ruby/ext/tk/lib/tkextlib/tktable.rb
new file mode 100644
index 0000000..385eb13
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktable.rb
@@ -0,0 +1,14 @@
+#
+# TkTable support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# load library
+require 'tkextlib/tktable/tktable'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb b/jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb
new file mode 100644
index 0000000..f707465
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb
@@ -0,0 +1,966 @@
+#
+# tkextlib/tktable/tktable.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/validation'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# TkPackage.require('Tktable', '2.8')
+TkPackage.require('Tktable')
+
+module Tk
+ class TkTable < TkWindow
+ PACKAGE_NAME = 'Tktable'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Tktable')
+ rescue
+ ''
+ end
+ end
+
+ class CellTag < TkObject
+ end
+
+ module ConfigMethod
+ end
+ end
+end
+
+module Tk::TkTable::ConfigMethod
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'cget', id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'configure', id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'multiline' << 'showtext' << 'wrap'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ super(id) << 'ellipsis'
+ end
+ private :__item_strval_optkeys
+
+ def __item_val2ruby_optkeys(id) # { key=>method, ... }
+ super(id).update('window'=>proc{|k,v| window(v)})
+ end
+ private :__item_val2ruby_optkeys
+
+ def tag_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['tag', tagid(tagOrId)], option)
+ end
+ def tag_cget(tagOrId, option)
+ itemcget(['tag', tagid(tagOrId)], option)
+ end
+ def tag_cget_strict(tagOrId, option)
+ itemcget_strict(['tag', tagid(tagOrId)], option)
+ end
+ def tag_configure(tagOrId, slot, value=None)
+ itemconfigure(['tag', tagid(tagOrId)], slot, value)
+ end
+ def tag_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['tag', tagid(tagOrId)], slot)
+ end
+ def current_tag_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['tag', tagid(tagOrId)], slot)
+ end
+
+ def window_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['window', tagid(tagOrId)], option)
+ end
+ def window_cget(tagOrId, option)
+ itemcget(['window', tagid(tagOrId)], option)
+ end
+ def window_cget_strict(tagOrId, option)
+ itemcget_strict(['window', tagid(tagOrId)], option)
+ end
+ def window_configure(tagOrId, slot, value=None)
+ if slot == :window || slot == 'window'
+ value = _epath(value)
+ elsif slot.kind_of?(Hash)
+ if slot.key?(:window) || slot.key?('window')
+ slot = _symbolkey2str(slot)
+ slot['window'] = _epath(slot['window'])
+ end
+ end
+ itemconfigure(['window', tagid(tagOrId)], slot, value)
+ end
+ def window_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['window', tagid(tagOrId)], slot)
+ end
+ def current_window_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['window', tagid(tagOrId)], slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+#####################################################
+
+class Tk::TkTable::CellTag
+ include TkTreatTagFont
+
+ CellTagID_TBL = TkCore::INTERP.create_table
+
+ (CellTag_ID = ['tktbl:celltag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ CellTagID_TBL.mutex.synchronize{ CellTagID_TBL.clear }
+ }
+
+ def self.id2obj(table, id)
+ tpath = table.path
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[tpath]
+ CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys=nil)
+ @parent = @t = parent
+ @tpath - parent.path
+ CellTag_ID.mutex.synchronize{
+ @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
+ CellTag_ID[1].succ!
+ }
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ configure(keys) if keys
+ end
+
+ def id
+ @id
+ end
+
+ def destroy
+ tk_call(@tpath, 'tag', 'delete', @id)
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ }
+ self
+ end
+ alias delete destroy
+
+ def exist?
+ @t.tag_exist?(@id)
+ end
+ def include?(idx)
+ @t.tag_include?(@id, idx)
+ end
+
+ def add_cell(*args)
+ @t.tag_cell(@id, *args)
+ end
+ def add_col(*args)
+ @t.tag_col(@id, *args)
+ end
+ def add_row(*args)
+ @t.tag_row(@id, *args)
+ end
+
+ def raise(target=None)
+ @t.tag_raise(@id, target)
+ end
+ def lower(target=None)
+ @t.tag_lower(@id, target)
+ end
+
+ def cget_tkstring(key)
+ @t.tag_cget_tkstring(@id, key)
+ end
+ def cget(key)
+ @t.tag_cget(@id, key)
+ end
+ def cget_strict(key)
+ @t.tag_cget_strict(@id, key)
+ end
+ def configure(key, val=None)
+ @t.tag_configure(@id, key, val)
+ end
+ def configinfo(key=nil)
+ @t.tag_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @t.current_tag_configinfo(@id, key)
+ end
+end
+
+class Tk::TkTable::NamedCellTag < Tk::TkTable::CellTag
+ def self.new(parent, name, keys=nil)
+ obj = nil
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
+ obj = CellTagID_TBL[parent.path][name]
+ else
+ #super(parent, name, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
+ end
+
+ def initialize(parent, name, keys=nil)
+ # dummy:: not called by 'new' method
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ configure(keys) if keys && ! keys.empty?
+ end
+end
+
+#####################################################
+
+class Tk::TkTable
+ TkCommandNames = ['table'.freeze].freeze
+ WidgetClassName = 'Table'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include Scrollable
+ include Tk::TkTable::ConfigMethod
+ include Tk::ValidateConfigure
+
+ def __destroy_hook__
+ Tk::TkTable::CelTag::CellTagID_TBL.mutex.synchronize{
+ Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ }
+ end
+
+ def __boolval_optkeys
+ super() << 'autoclear' << 'flashmode' << 'invertselected' <<
+ 'multiline' << 'selecttitle' << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'colseparator' << 'ellipsis' << 'rowseparator' << 'sparsearray'
+ end
+ private :__strval_optkeys
+
+
+ #################################
+
+ class BrowseCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?x, :cursor ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?s, :last_index ],
+ [ ?S, ?s, :new_index ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['browsecommand', 'browsecmd']
+ end
+ end
+ #--------------------------------
+ class CellCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?m, :rw_mode ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?v, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ],
+ [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ TkComm._get_eval_string(val)
+ end
+ end
+
+ def self._config_keys
+ ['command']
+ end
+ end
+ #--------------------------------
+ class SelectionCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :sel_columns ],
+ [ ?C, ?s, :sel_area ],
+ [ ?i, ?n, :total ],
+ [ ?r, ?n, :sel_rows ],
+ [ ?s, ?s, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val.to_s
+ end
+ end
+
+ def self._config_keys
+ ['selectioncommand', 'selcmd']
+ end
+ end
+ #--------------------------------
+ class ValidateCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?x, :cursor ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?v, :current_value ],
+ [ ?S, ?v, :new_value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['vcmd', 'validatecommand']
+ end
+ end
+
+ #################################
+
+ def __validation_class_list
+ super() <<
+ BrowseCommand << CellCommand << SelectionCommand << ValidateCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, BrowseCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, CellCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, SelectionCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, ValidateCommand)
+
+ #################################
+
+ def activate(idx)
+ tk_send('activate', tagid(idx))
+ end
+
+ def bbox(idx)
+ list(tk_send('bbox', tagid(idx)))
+ end
+
+ def border_mark(x, y)
+ simplelist(tk_send('border', 'mark', x, y))
+ end
+ def border_mark_row(x, y)
+ tk_send('border', 'mark', x, y, 'row')
+ end
+ def border_mark_col(x, y)
+ tk_send('border', 'mark', x, y, 'col')
+ end
+ def border_dragto(x, y)
+ tk_send('border', 'dragto', x, y)
+ end
+
+ def clear_cache(first=None, last=None)
+ tk_send('clear', 'cache', tagid(first), tagid(last))
+ self
+ end
+ def clear_sizes(first=None, last=None)
+ tk_send('clear', 'sizes', tagid(first), tagid(last))
+ self
+ end
+ def clear_tags(first=None, last=None)
+ tk_send('clear', 'tags', tagid(first), tagid(last))
+ self
+ end
+ def clear_all(first=None, last=None)
+ tk_send('clear', 'all', tagid(first), tagid(last))
+ self
+ end
+
+ def curselection
+ simplelist(tk_send('curselection'))
+ end
+ def curselection=(val)
+ tk_send('curselection', val)
+ val
+ end
+
+ def curvalue
+ tk_tcl2ruby(tk_send('curvalue'), true, false)
+ end
+ def curvalue=(val)
+ tk_send('curvalue', val)
+ val
+ end
+
+ def delete_active(idx1, idx2=None)
+ tk_send('delete', 'active', tagid(idx1), tagid(idx2))
+ self
+ end
+ def delete_cols(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('delete', 'cols', *params)
+ self
+ end
+ def delete_rows(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('delete', 'rows', *params)
+ self
+ end
+
+ def get(idx)
+ tk_tcl2ruby(tk_send('get', tagid(idx)), true, false)
+ end
+ def get_area(idx1, idx2)
+ simplelist(tk_send('get', tagid(idx1), tagid(idx2))).collect{|v|
+ tk_tcl2ruby(v, true, false)
+ }
+ end
+
+ def height_list
+ list(tk_send('height'))
+ end
+ def height(row)
+ number(tk_send('height', row))
+ end
+ def set_height(*pairs)
+ tk_send('height', *(pairs.flatten))
+ self
+ end
+
+ def hidden_list
+ simplelist(tk_send('hidden'))
+ end
+ def hidden?(idx, *args)
+ if args.empty?
+ if (ret = tk_send('hidden', tagid(idx))) == ''
+ false
+ else
+ ret
+ end
+ else
+ bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)})))
+ end
+ end
+
+ def icursor
+ number(tk_send('icursor'))
+ end
+ def icursor_set(idx)
+ number(tk_send('icursor', tagid(idx)))
+ end
+
+ def index(idx)
+ tk_send('index', tagid(idx))
+ end
+ def row_index(idx)
+ number(tk_send('index', tagid(idx), 'row'))
+ end
+ def col_index(idx)
+ number(tk_send('index', tagid(idx), 'col'))
+ end
+
+ def insert_active(idx, val)
+ tk_send('insert', 'active', tagid(idx), val)
+ self
+ end
+ def insert_cols(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params.concat(args)
+ params << tagid(args.shift)
+ tk_send('insert', 'cols', *params)
+ self
+ end
+ def insert_rows(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('insert', 'rows', *params)
+ self
+ end
+
+ # def postscript(*args)
+ # tk_send('postscript', *args)
+ # end
+
+ def reread
+ tk_send('reread')
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(idx)
+ tk_send('see', tagid(idx))
+ self
+ end
+
+ def selection_anchor(idx)
+ tk_send('selection', 'anchor', tagid(idx))
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send('selection', 'clear', tagid(first), tagid(last))
+ self
+ end
+ def selection_clear_all
+ selection_clear('all')
+ end
+ def selection_include?(idx)
+ bool(tk_send('selection', 'includes', tagid(idx)))
+ end
+ def selection_present
+ bool(tk_send('selection', 'present'))
+ end
+ def selection_set(first, last=None)
+ tk_send('selection', 'set', tagid(first), tagid(last))
+ self
+ end
+
+ def set(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', *args)
+ self
+ end
+ def set_row(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'row', *args)
+ self
+ end
+ def set_col(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'col', *args)
+ self
+ end
+=begin
+ def set(*pairs) # idx, val, idx, val, ... OR [idx, val], [idx, val], ...
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << tagid(idx) << val }
+ tk_send('set', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', *args)
+ end
+ self
+ end
+ def set_row(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << tagid(idx) << val }
+ tk_send('set', 'row', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'row', *args)
+ end
+ self
+ end
+ def set_col(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << idx << val }
+ tk_send('set', 'col', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'col', *args)
+ end
+ self
+ end
+=end
+
+ def spans
+ simplelist(tk_send('spans')).collect{|inf|
+ lst = simplelist(inf)
+ idx = lst[0]
+ rows, cols = lst[1].split(',').map!{|n| Integer(n)}
+ [idx [rows, cols]]
+ }
+ end
+ alias span_list spans
+ def span(idx)
+ lst = simplelist(tk_send('spans', tagid(idx)))
+ idx = lst[0]
+ rows, cols = lst[1].split(',').map!{|n| Integer(n)}
+ [idx [rows, cols]]
+ end
+ def set_spans(*pairs)
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ val = pairs[i+1]
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ self
+ end
+=begin
+ def set_spans(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val|
+ args << tagid(idx)
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ val = pairs[i+1]
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ end
+ self
+ end
+=end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::TkTable::CellTag)
+ tag.id
+ elsif tag.kind_of?(Array)
+ if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer)
+ # [row, col]
+ tag.join(',')
+ else
+ tag
+ end
+ else
+ tag
+ end
+ end
+
+ def tagid2obj(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ else
+ tagid
+ end
+ else
+ tagid
+ end
+ }
+ end
+
+ def tag_cell(tag, *cells)
+ tk_send('tag', 'cell', tagid(tag), *(cells.collect{|idx| tagid(idx)}))
+ self
+ end
+ def tag_reset(*cells)
+ tk_send('tag', 'cell', '', *(cells.collect{|idx| tagid(idx)}))
+ self
+ end
+ def tag_col(tag, *cols)
+ tk_send('tag', 'col', tagid(tag), *cols)
+ self
+ end
+ def tag_col_reset(*cols)
+ tk_send('tag', 'col', '', *cols)
+ self
+ end
+ def tag_delete(tag)
+ tk_send('tag', 'delete', tagid(tag))
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path]
+ if tag.kind_of? Tk::TkTable::CellTag
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
+ else
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ end
+ end
+ }
+ self
+ end
+ def tag_exist?(tag)
+ bool(tk_send('tag', 'exists', tagid(tag)))
+ end
+ def tag_include?(tag, idx)
+ bool(tk_send('tag', 'includes', tagid(tag), tagid(idx)))
+ end
+ def tag_lower(tag, target=None)
+ tk_send('tag', 'lower', tagid(tag), tagid(target))
+ self
+ end
+ def tag_names(pat=None)
+ simplelist(tk_send('tag', 'names', pat)).collect{|tag| tagid2obj(tag)}
+ end
+ def tag_raise(tag, target=None)
+ tk_send('tag', 'raise', tagid(tag), tagid(target))
+ self
+ end
+ def tag_row(tag, *rows)
+ tk_send('tag', 'row', tagid(tag), *rows)
+ self
+ end
+ def tag_row_reset(*rows)
+ tk_send('tag', 'row', '', *rows)
+ self
+ end
+
+ def validate(idx)
+ bool(tk_send('validate', tagid(idx)))
+ end
+
+ def width_list
+ list(tk_send('width'))
+ end
+ def width(row)
+ number(tk_send('width', row))
+ end
+ def set_width(*pairs)
+ tk_send('width', *(pairs.flatten))
+ self
+ end
+
+ def window_delete(*args)
+ tk_send('window', 'delete', *(args.collect{|idx| tagid(idx)}))
+ self
+ end
+ def window_move(from_idx, to_idx)
+ tk_send('window', 'move', tagid(from_idx), tagid(to_idx))
+ self
+ end
+ def window_names(pat=None)
+ simplelist(tk_send('window', 'names', pat))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktrans.rb b/jni/ruby/ext/tk/lib/tkextlib/tktrans.rb
new file mode 100644
index 0000000..c5de5be
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktrans.rb
@@ -0,0 +1,14 @@
+#
+# TkTrans support (win32 only)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktrans/setup.rb'
+
+# load library
+require 'tkextlib/tktrans/tktrans'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb
new file mode 100644
index 0000000..e051c09
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb
@@ -0,0 +1,64 @@
+#
+# TkTrans support (win32 only)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktrans/setup.rb'
+
+TkPackage.require('tktrans') rescue Tk.load_tcllibrary('tktrans')
+
+module Tk
+ module TkTrans
+ PACKAGE_NAME = 'tktrans'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tktrans')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class TkWindow
+ def tktrans_set_image(img)
+ tk_send('tktrans::setwidget', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::setwidget', @path)
+ end
+end
+
+class Tk::Root
+ undef tktrans_set_image, tktrans_get_image
+
+ def tktrans_set_image(img)
+ tk_send('tktrans::settoplevel', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::settoplevel', @path)
+ end
+end
+
+class Tk::Toplevel
+ undef tktrans_set_image, tktrans_get_image
+
+ def tktrans_set_image(img)
+ tk_send('tktrans::settoplevel', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::settoplevel', @path)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/treectrl.rb b/jni/ruby/ext/tk/lib/tkextlib/treectrl.rb
new file mode 100644
index 0000000..1944fb8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/treectrl.rb
@@ -0,0 +1,13 @@
+#
+# TkTreeCtrl support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/treectrl/setup.rb'
+
+# load library
+require 'tkextlib/treectrl/tktreectrl'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
new file mode 100644
index 0000000..1879a53
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
@@ -0,0 +1,2522 @@
+#
+# tkextlib/treectrl/tktreectrl.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/treectrl/setup.rb'
+
+# TkPackage.require('treectrl', '1.0')
+# TkPackage.require('treectrl', '1.1')
+TkPackage.require('treectrl')
+
+module Tk
+ class TreeCtrl < TkWindow
+ BindTag_FileList = TkBindTag.new_by_name('TreeCtrlFileList')
+
+ PACKAGE_NAME = 'treectrl'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('treectrl')
+ rescue
+ ''
+ end
+ end
+
+ HasColumnCreateCommand =
+ (TkPackage.vcompare(self.package_version, '1.1') >= 0)
+
+ # dummy ::
+ # pkgIndex.tcl of TreeCtrl-1.0 doesn't support auto_load for
+ # 'loupe' command (probably it is bug, I think).
+ # So, calling a 'treectrl' command for loading the dll with
+ # the auto_load facility.
+ begin
+ tk_call('treectrl')
+ rescue
+ end
+ def self.loupe(img, x, y, w, h, zoom)
+ # NOTE: platform == 'unix' only
+
+ # img => TkPhotoImage
+ # x, y => screen coords
+ # w, h => magnifier width and height
+ # zoom => zooming rate
+ Tk.tk_call_without_enc('loupe', img, x, y, w, h, zoom)
+ end
+
+ def self.text_layout(font, text, keys={})
+ TkComm.list(Tk.tk_call_without_enc('textlayout', font, text, keys))
+ end
+
+ def self.image_tint(img, color, alpha)
+ Tk.tk_call_without_enc('imagetint', img, color, alpha)
+ end
+
+ class NotifyEvent < TkUtil::CallbackSubst
+ end
+
+ module ConfigMethod
+ end
+ end
+ TreeCtrl_Widget = TreeCtrl
+end
+
+##############################################
+
+class Tk::TreeCtrl::NotifyEvent
+ # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
+ KEY_TBL = [
+ [ ?c, ?n, :item_num ],
+ [ ?d, ?s, :detail ],
+ [ ?D, ?l, :items ],
+ [ ?e, ?e, :event ],
+ [ ?I, ?n, :id ],
+ [ ?l, ?n, :lower_bound ],
+ [ ?p, ?n, :active_id ],
+ [ ?P, ?e, :pattern ],
+ [ ?S, ?l, :sel_items ],
+ [ ?T, ?w, :widget ],
+ [ ?u, ?n, :upper_bound ],
+ [ ?W, ?o, :object ],
+ [ ??, ?x, :parm_info ],
+ nil
+ ]
+
+ # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?l, TkComm.method(:list) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ case val
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(val[1..-2])
+ when /^<[^<>]+>$/
+ val[1..-2]
+ else
+ val
+ end
+ }
+ ],
+
+ [ ?o, proc{|val| TkComm.tk_tcl2ruby(val)} ],
+
+ [ ?x, proc{|val|
+ begin
+ inf = {}
+ Hash[*(TkComm.list(val))].each{|k, v|
+ if keyinfo = KEY_TBL.assoc(k[0])
+ if cmd = PROC_TBL.assoc(keyinfo[1])
+ begin
+ new_v = cmd.call(v)
+ v = new_v
+ rescue
+ end
+ end
+ end
+ inf[k] = v
+ }
+ inf
+ rescue
+ val
+ end
+ } ],
+
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
+ #
+ # _get_subst_key() and _get_all_subst_keys() generates key-string
+ # which describe how to convert callback arguments to ruby objects.
+ # When binding parameters are given, use _get_subst_key().
+ # But when no parameters are given, use _get_all_subst_keys() to
+ # create a Event class object as a callback parameter.
+ #
+ # scan_args() is used when doing callback. It convert arguments
+ # ( which are Tcl strings ) to ruby objects based on the key string
+ # that is generated by _get_subst_key() or _get_all_subst_keys().
+ #
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+end
+
+##############################################
+
+module Tk::TreeCtrl::ConfigMethod
+ include TkItemConfigMethod
+
+ def treectrl_tagid(key, obj)
+ if key.kind_of?(Array)
+ key = key.join(' ')
+ else
+ key = key.to_s
+ end
+
+ if (obj.kind_of?(Tk::TreeCtrl::Column) ||
+ obj.kind_of?(Tk::TreeCtrl::Element) ||
+ obj.kind_of?(Tk::TreeCtrl::Item) ||
+ obj.kind_of?(Tk::TreeCtrl::Style))
+ obj = obj.id
+ end
+
+ case key
+ when 'column'
+ obj
+
+ when 'debug'
+ None
+
+ when 'dragimage'
+ None
+
+ when 'element'
+ obj
+
+ when 'item element'
+ obj
+
+ when 'marquee'
+ None
+
+ when 'notify'
+ obj
+
+ when 'style'
+ obj
+
+ else
+ obj
+ end
+ end
+
+ def tagid(mixed_id)
+ if mixed_id == 'debug'
+ ['debug', None]
+ elsif mixed_id == 'dragimage'
+ ['dragimage', None]
+ elsif mixed_id == 'marquee'
+ ['marquee', None]
+ elsif mixed_id.kind_of?(Array)
+ [mixed_id[0], treectrl_tagid(*mixed_id)]
+ else
+ tagid(mixed_id.split(':'))
+ end
+ end
+
+ def __item_cget_cmd(mixed_id)
+ if mixed_id[0] == 'column' && mixed_id[1] == 'drag'
+ return [self.path, 'column', 'dragcget']
+ end
+
+ if mixed_id[1].kind_of?(Array)
+ id = mixed_id[1]
+ else
+ id = [mixed_id[1]]
+ end
+
+ if mixed_id[0].kind_of?(Array)
+ ([self.path].concat(mixed_id[0]) << 'cget').concat(id)
+ else
+ [self.path, mixed_id[0], 'cget'].concat(id)
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(mixed_id)
+ if mixed_id[0] == 'column' && mixed_id[1] == 'drag'
+ return [self.path, 'column', 'dragconfigure']
+ end
+
+ if mixed_id[1].kind_of?(Array)
+ id = mixed_id[1]
+ else
+ id = [mixed_id[1]]
+ end
+
+ if mixed_id[0].kind_of?(Array)
+ ([self.path].concat(mixed_id[0]) << 'configure').concat(id)
+ else
+ [self.path, mixed_id[0], 'configure'].concat(id)
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ key = id[0]
+ if key.kind_of?(Array)
+ key = key.join(' ')
+ end
+
+ tag = id[1]
+ if tag.kind_of?(Array)
+ tag = tag.join(' ')
+ end
+
+ id = [key, tag].join(':')
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def __item_configinfo_struct(id)
+ if id.kind_of?(Array) && id[0].to_s == 'notify'
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>1}
+ else
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
+ end
+ end
+ private :__item_configinfo_struct
+
+
+ def __item_font_optkeys(id)
+ if id.kind_of?(Array) && (id[0] == 'element' ||
+ (id[0].kind_of?(Array) && id[0][1] == 'element'))
+ []
+ else
+ ['font']
+ end
+ end
+ private :__item_font_optkeys
+
+ def __item_numstrval_optkeys(id)
+ if id == 'debug'
+ ['displaydelay']
+ else
+ super(id)
+ end
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_boolval_optkeys(id)
+ if id == 'debug'
+ ['data', 'display', 'enable', 'span', 'textlayout']
+ elsif id == 'dragimage'
+ ['visible']
+ elsif id == 'marquee'
+ ['visible']
+ elsif id.kind_of?(Array)
+ case id[0]
+ when 'item'
+ ['visible', 'wrap', 'open', 'returnid', 'visible']
+ when 'column'
+ if id[1] == 'drag'
+ ['enable']
+ else
+ ['button', 'expand', 'resize', 'squeeze', 'sunken',
+ 'visible', 'widthhack']
+ end
+ when 'element'
+ ['draw', 'filled', 'showfocus', 'clip', 'destroy']
+ when 'notify'
+ ['active']
+ when 'style'
+ ['detach', 'indent', 'visible']
+ else
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
+ ['filled', 'showfocus']
+ else
+ super(id)
+ end
+ end
+ else
+ super(id)
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ if id == 'debug'
+ ['erasecolor']
+ elsif id.kind_of?(Array)
+ case id[0]
+ when 'column'
+ if id[1] == 'drag'
+ ['indicatorcolor']
+ else
+ super(id) << 'textcolor'
+ end
+ when 'element'
+ super(id) << 'fill' << 'outline' << 'format'
+ else
+ super(id)
+ end
+ else
+ super(id)
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ if id.kind_of?(Array)
+ case id[0]
+ when 'column'
+ ['itembackground']
+ when 'element'
+ ['relief']
+ when 'style'
+ ['union']
+ else
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
+ ['relief']
+ else
+ []
+ end
+ end
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_val2ruby_optkeys(id)
+ if id.kind_of?(Array)
+ case id[0]
+ when 'item'
+ { 'button' => proc{|id,val| (val == 'auto')? val: TkComm.bool(val)} }
+ else
+ []
+ end
+ else
+ []
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def __item_keyonly_optkeys(id) # { def_key=>(undef_key|nil), ... }
+ {
+ 'notreally'=>nil,
+ 'increasing'=>'decreasing',
+ 'decreasing'=>'increasing',
+ 'ascii'=>nil,
+ 'dictionary'=>nil,
+ 'integer'=>nil,
+ 'real'=>nil
+ }
+ end
+ private :__item_keyonly_optkeys
+
+ def column_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['column', tagOrId], option)
+ end
+ def column_cget(tagOrId, option)
+ itemcget(['column', tagOrId], option)
+ end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
+ def column_configure(tagOrId, slot, value=None)
+ itemconfigure(['column', tagOrId], slot, value)
+ end
+ def column_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['column', tagOrId], slot)
+ end
+ def current_column_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['column', tagOrId], slot)
+ end
+
+ def column_dragcget_tkstring(option)
+ itemcget_tkstring(['column', 'drag'], option)
+ end
+ def column_dragcget(option)
+ itemcget(['column', 'drag'], option)
+ end
+ def column_dragcget_strict(option)
+ itemcget_strict(['column', 'drag'], option)
+ end
+ def column_dragconfigure(slot, value=None)
+ itemconfigure(['column', 'drag'], slot, value)
+ end
+ def column_dragconfiginfo(slot=nil)
+ itemconfiginfo(['column', 'drag'], slot)
+ end
+ def current_column_dragconfiginfo(slot=nil)
+ current_itemconfiginfo(['column', 'drag'], slot)
+ end
+
+ def debug_cget_tkstring(option)
+ itemcget_tkstring('debug', option)
+ end
+ def debug_cget(option)
+ itemcget('debug', option)
+ end
+ def debug_cget_strict(option)
+ itemcget_strict('debug', option)
+ end
+ def debug_configure(slot, value=None)
+ itemconfigure('debug', slot, value)
+ end
+ def debug_configinfo(slot=nil)
+ itemconfiginfo('debug', slot)
+ end
+ def current_debug_configinfo(slot=nil)
+ current_itemconfiginfo('debug', slot)
+ end
+
+ def dragimage_cget_tkstring(option)
+ itemcget_tkstring('dragimage', option)
+ end
+ def dragimage_cget(option)
+ itemcget('dragimage', option)
+ end
+ def dragimage_cget_strict(option)
+ itemcget_strict('dragimage', option)
+ end
+ def dragimage_configure(slot, value=None)
+ itemconfigure('dragimage', slot, value)
+ end
+ def dragimage_configinfo(slot=nil)
+ itemconfiginfo('dragimage', slot)
+ end
+ def current_dragimage_configinfo(slot=nil)
+ current_itemconfiginfo('dragimage', slot)
+ end
+
+ def element_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['element', tagOrId], option)
+ end
+ def element_cget(tagOrId, option)
+ itemcget(['element', tagOrId], option)
+ end
+ def element_cget_strict(tagOrId, option)
+ itemcget_strict(['element', tagOrId], option)
+ end
+ def element_configure(tagOrId, slot, value=None)
+ itemconfigure(['element', tagOrId], slot, value)
+ end
+ def element_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['element', tagOrId], slot)
+ end
+ def current_element_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['element', tagOrId], slot)
+ end
+
+ def item_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['item', tagOrId], option)
+ end
+ def item_cget(tagOrId, option)
+ itemcget(['item', tagOrId], option)
+ end
+ def item_cget_strict(tagOrId, option)
+ itemcget_strict(['item', tagOrId], option)
+ end
+ def item_configure(tagOrId, slot, value=None)
+ itemconfigure(['item', tagOrId], slot, value)
+ end
+ def item_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['item', tagOrId], slot)
+ end
+ def current_item_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['item', tagOrId], slot)
+ end
+
+ def item_element_cget_tkstring(item, column, elem, option)
+ itemcget_tkstring([['item', 'element'], [item, column, elem]], option)
+ end
+ def item_element_cget(item, column, elem, option)
+ itemcget([['item', 'element'], [item, column, elem]], option)
+ end
+ def item_element_cget_strict(item, column, elem, option)
+ itemcget_strict([['item', 'element'], [item, column, elem]], option)
+ end
+ def item_element_configure(item, column, elem, slot, value=None)
+ itemconfigure([['item', 'element'], [item, column, elem]], slot, value)
+ end
+ def item_element_configinfo(item, column, elem, slot=nil)
+ itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
+ end
+ def current_item_element_configinfo(item, column, elem, slot=nil)
+ current_itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
+ end
+
+ def marquee_cget_tkstring(option)
+ itemcget_tkstring('marquee', option)
+ end
+ def marquee_cget(option)
+ itemcget('marquee', option)
+ end
+ def marquee_cget_strict(option)
+ itemcget_strict('marquee', option)
+ end
+ def marquee_configure(slot, value=None)
+ itemconfigure('marquee', slot, value)
+ end
+ def marquee_configinfo(slot=nil)
+ itemconfiginfo('marquee', slot)
+ end
+ def current_marquee_configinfo(slot=nil)
+ current_itemconfiginfo('marquee', slot)
+ end
+
+ def notify_cget_tkstring(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(['notify', [win, pattern]])) << "-#{option}")), false, true)[-1]
+ end
+ def notify_cget(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ current_itemconfiginfo(['notify', [win, pattern]])[option.to_s]
+ end
+ def notify_cget_strict(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ info = current_itemconfiginfo(['notify', [win, pattern]])
+ option = option.to_s
+ unless info.has_key?(option)
+ fail RuntimeError, "unknown option \"#{option}\""
+ else
+ info[option]
+ end
+ end
+ def notify_configure(win, pattern, slot, value=None)
+ pattern = "<#{pattern}>"
+ itemconfigure(['notify', [win, pattern]], slot, value)
+ end
+ def notify_configinfo(win, pattern, slot=nil)
+ pattern = "<#{pattern}>"
+ itemconfiginfo(['notify', [win, pattern]], slot)
+ end
+ def current_notify_configinfo(tagOrId, slot=nil)
+ pattern = "<#{pattern}>"
+ current_itemconfiginfo(['notify', [win, pattern]], slot)
+ end
+
+ def style_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['style', tagOrId], option)
+ end
+ def style_cget(tagOrId, option)
+ itemcget(['style', tagOrId], option)
+ end
+ def style_cget_strict(tagOrId, option)
+ itemcget_strict(['style', tagOrId], option)
+ end
+ def style_configure(tagOrId, slot, value=None)
+ itemconfigure(['style', tagOrId], slot, value)
+ end
+ def style_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['style', tagOrId], slot)
+ end
+ def current_style_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['style', tagOrId], slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+##############################################
+
+class Tk::TreeCtrl
+ include Tk::TreeCtrl::ConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['treectrl'.freeze].freeze
+ WidgetClassName = 'TreeCtrl'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ #########################
+
+ def __destroy_hook__
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
+ }
+ end
+
+ #########################
+
+ def __strval_optkeys
+ super() + [
+ 'buttoncolor', 'columnprefix', 'itemprefix', 'linecolor'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ [
+ 'itemwidthequal', 'usetheme',
+ 'showbuttons', 'showheader', 'showlines', 'showroot',
+ 'showrootbutton', 'showrootlines', 'showrootchildbuttons'
+ ]
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ [ 'defaultstyle' ]
+ end
+ private :__listval_optkeys
+
+ #########################
+
+ def install_bind(cmd, *args)
+ install_bind_for_event_class(Tk::TreeCtrl::NotifyEvent, cmd, *args)
+ end
+
+ #########################
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ #########################
+
+ def activate(desc)
+ tk_send('activate', desc)
+ self
+ end
+
+ def canvasx(x)
+ number(tk_send('canvasx', x))
+ end
+
+ def canvasy(y)
+ number(tk_send('canvasy', y))
+ end
+
+ def collapse(*dsc)
+ tk_send_without_enc('collapse', *(dsc.map!{|d| _get_eval_string(d, true)}))
+ self
+ end
+
+ def collapse_recurse(*dsc)
+ tk_send_without_enc('collapse', '-recurse',
+ *(dsc.map!{|d| _get_eval_string(d, true)}))
+ self
+ end
+
+ def column_bbox(idx)
+ list(tk_send('column', 'bbox', idx))
+ end
+
+ def column_compare(column1, op, column2)
+ bool(tk_send('column', 'compare', column1, op, column2))
+ end
+
+ def column_count
+ num_or_str(tk_send('column', 'count'))
+ end
+
+ def column_create(keys=nil)
+ if keys && keys.kind_of?(Hash)
+ num_or_str(tk_send('column', 'create', *hash_kv(keys)))
+ else
+ num_or_str(tk_send('column', 'create'))
+ end
+ end
+
+ def column_delete(idx)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
+ end
+ }
+ tk_send('column', 'delete', idx)
+ self
+ end
+
+ def column_index(idx)
+ num_or_str(tk_send('column', 'index', idx))
+ end
+
+ def column_id(idx)
+ tk_send('column', 'id', idx)
+ end
+
+ def column_list(visible=false)
+ if visible
+ simplelist(tk_send('column', 'list', '-visible'))
+ else
+ simplelist(tk_send('column', 'list'))
+ end
+ end
+ def column_visible_list
+ column_list(true)
+ end
+
+ def column_move(idx, before)
+ tk_send('column', 'move', idx, before)
+ self
+ end
+
+ def column_needed_width(idx)
+ num_or_str(tk_send('column', 'neededwidth', idx))
+ end
+ alias column_neededwidth column_needed_width
+
+ def column_order(column, visible=false)
+ if visible
+ num_or_str(tk_send('column', 'order', column, '-visible'))
+ else
+ num_or_str(tk_send('column', 'order', column))
+ end
+ end
+ def column_visible_order(column)
+ column_order(column, true)
+ end
+
+ def column_width(idx)
+ num_or_str(tk_send('column', 'width', idx))
+ end
+
+ def compare(item1, op, item2)
+ bool(tk_send('compare', item1, op, item2))
+ end
+
+ def contentbox()
+ list(tk_send('contentbox'))
+ end
+
+ def depth(item=None)
+ num_or_str(tk_send_without_enc('depth', _get_eval_string(item, true)))
+ end
+
+ def dragimage_add(item, *args)
+ tk_send('dragimage', 'add', item, *args)
+ self
+ end
+
+ def dragimage_clear()
+ tk_send('dragimage', 'clear')
+ self
+ end
+
+ def dragimage_offset(*args) # x, y
+ if args.empty?
+ list(tk_send('dragimage', 'offset'))
+ else
+ tk_send('dragimage', 'offset', *args)
+ self
+ end
+ end
+
+ def dragimage_visible(*args) # mode
+ if args..empty?
+ bool(tk_send('dragimage', 'visible'))
+ else
+ tk_send('dragimage', 'visible', *args)
+ self
+ end
+ end
+ def dragimage_visible?
+ dragimage_visible()
+ end
+
+ def debug_dinfo
+ tk_send('debug', 'dinfo')
+ self
+ end
+
+ def debug_scroll
+ tk_send('debug', 'scroll')
+ end
+
+ def element_create(elem, type, keys=nil)
+ if keys && keys.kind_of?(Hash)
+ tk_send('element', 'create', elem, type, *hash_kv(keys))
+ else
+ tk_send('element', 'create', elem, type)
+ end
+ end
+
+ def element_delete(*elems)
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
+ elems.each{|elem|
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
+ }
+ end
+ }
+ tk_send('element', 'delete', *elems)
+ self
+ end
+
+ def element_names()
+ list(tk_send('element', 'names')).collect!{|elem|
+ Tk::TreeCtrl::Element.id2obj(self, elem)
+ }
+ end
+
+ def _conv_element_perstate_val(opt, val)
+ case opt
+ when 'background', 'foreground', 'fill', 'outline', 'format'
+ val
+ when 'draw', 'filled', 'showfocus', 'destroy'
+ bool(val)
+ else
+ tk_tcl2ruby(val)
+ end
+ end
+ private :_conv_element_perstate_val
+
+ def element_perstate(elem, opt, st_list)
+ tk_send('element', 'perstate', elem, "-{opt}", st_list)
+ end
+
+ def element_type(elem)
+ tk_send('element', 'type', elem)
+ end
+
+ def element_class(elem)
+ Tk::TreeCtrl::Element.type2class(element_type(elem))
+ end
+
+ def expand(*dsc)
+ tk_send('expand', *dsc)
+ self
+ end
+
+ def expand_recurse(*dsc)
+ tk_send('expand', '-recurse', *dsc)
+ self
+ end
+
+ def identify(x, y)
+ lst = list(tk_send('identify', x, y))
+
+ if lst[0] == 'item'
+ lst[1] = Tk::TreeCtrl::Item.id2obj(self, lst[1])
+ size = lst.size
+ i = 2
+ while i < size
+ case lst[i]
+ when 'line'
+ i += 1
+ lst[i] = Tk::TreeCtrl::Item.id2obj(self, lst[i])
+ i += 1
+
+ when 'button'
+ i += 1
+
+ when 'column'
+ i += 2
+
+ when 'elem'
+ i += 1
+ lst[i] = Tk::TreeCtrl::Element.id2obj(self, lst[i])
+ i += 1
+
+ else
+ i += 1
+ end
+ end
+ end
+
+ lst
+ end
+
+ def index(idx)
+ num_or_str(tk_send('index', idx))
+ end
+
+ def item_ancestors(item)
+ list(tk_send('item', 'ancestors', item)).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def item_bbox(item, *args)
+ list(tk_send('item', 'bbox', item, *args))
+ end
+
+ def item_children(item)
+ list(tk_send('item', 'children', item)).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def item_collapse(item)
+ tk_send_without_enc('item', 'collapse', _get_eval_string(item, true))
+ self
+ end
+
+ def item_collapse_recurse(item)
+ tk_send_without_enc('item', 'collapse',
+ _get_eval_string(item, true), '-recurse')
+ self
+ end
+
+ def item_compare(item1, op, item2)
+ bool(tk_send('item', 'compare', item1, op, item2))
+ end
+
+ def item_complex(item, *args)
+ tk_send_without_enc('item', 'complex',
+ _get_eval_string(item, true),
+ *(args.map!{|arg| _get_eval_string(arg, true)}))
+ self
+ end
+
+ def item_count
+ num_or_str(tk_send('item', 'count'))
+ end
+
+ def item_create(keys={})
+ num_or_str(tk_send_without_enc('item', 'create', *hash_kv(keys, true)))
+ end
+
+ def _erase_children(item)
+ item_children(item).each{|i| _erase_children(i)}
+ # table is already locked
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].delete(item)
+ end
+ private :_erase_children
+
+ def item_delete(first, last=None)
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
+ if first == 'all' || first == :all || last == 'all' || last == :all
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
+ elsif last == None
+ _erase_children(first)
+ else
+ self.range(first, last).each{|id|
+ _erase_children(id)
+ }
+ end
+ end
+ }
+ tk_send('item', 'delete', first, last)
+ self
+ end
+
+ def item_dump(item)
+ list(tk_send('item', 'dump', item))
+ end
+
+ def item_dump_hash(item)
+ Hash[*list(tk_send('item', 'dump', item))]
+ end
+
+ def item_element_actual(item, column, elem, key)
+ tk_send('item', 'element', 'actual', item, column, elem, "-#{key}")
+ end
+
+ def item_element_perstate(elem, opt, st_list)
+ tk_send('item', 'element', 'perstate', elem, "-{opt}", st_list)
+ end
+
+ def item_expand(item)
+ tk_send('item', 'expand', item)
+ self
+ end
+
+ def item_expand_recurse(item)
+ tk_send('item', 'expand', item, '-recurse')
+ self
+ end
+
+ def item_firstchild(parent, child=nil)
+ if child
+ tk_send_without_enc('item', 'firstchild',
+ _get_eval_string(parent, true),
+ _get_eval_string(child, true))
+ self
+ else
+ id = num_or_str(tk_send_without_enc('item', 'firstchild',
+ _get_eval_string(parent, true)))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_first_child item_firstchild
+
+ def item_hasbutton(item, st=None)
+ if st == None
+ bool(tk_send_without_enc('item', 'hasbutton',
+ _get_eval_string(item, true)))
+ else
+ tk_send_without_enc('item', 'hasbutton',
+ _get_eval_string(item, true),
+ _get_eval_string(st))
+ self
+ end
+ end
+ alias item_has_button item_hasbutton
+
+ def item_hasbutton?(item)
+ item_hasbutton(item)
+ end
+ alias item_has_button? item_hasbutton?
+
+ def item_id(item)
+ tk_send('item', 'id', item)
+ end
+
+ def item_image(item, column=nil, *args)
+ if args.empty?
+ if column
+ img = tk_send('item', 'image', item, column)
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
+ else
+ simplelist(tk_send('item', 'image', item)).collect!{|img|
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
+ }
+ end
+ else
+ tk_send('item', 'image', item, column, *args)
+ self
+ end
+ end
+ def get_item_image(item, column=nil)
+ item_image(item, column)
+ end
+ def set_item_image(item, col, img, *args)
+ item_image(item, col, img, *args)
+ end
+
+ def item_index(item)
+ list(tk_send('item', 'index', item))
+ end
+
+ def item_isancestor(item, des)
+ bool(tk_send('item', 'isancestor', item, des))
+ end
+ alias item_is_ancestor item_isancestor
+ alias item_isancestor? item_isancestor
+ alias item_is_ancestor? item_isancestor
+
+ def item_isopen(item)
+ bool(tk_send('item', 'isopen', item))
+ end
+ alias item_is_open item_isopen
+ alias item_isopen? item_isopen
+ alias item_is_open? item_isopen
+ alias item_isopened? item_isopen
+ alias item_is_opened? item_isopen
+
+ def item_lastchild(parent, child=nil)
+ if child
+ tk_send_without_enc('item', 'lastchild',
+ _get_eval_string(parent, true),
+ _get_eval_string(child, true))
+ self
+ else
+ id = num_or_str(tk_send_without_enc('item', 'lastchild',
+ _get_eval_string(parent, true)))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_last_child item_lastchild
+
+ def item_nextsibling(sibling, nxt=nil)
+ if nxt
+ tk_send('item', 'nextsibling', sibling, nxt)
+ self
+ else
+ id = num_or_str(tk_send('item', 'nextsibling', sibling))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_next_sibling item_nextsibling
+
+ def item_numchildren(item)
+ number(tk_send_without_enc('item', 'numchildren',
+ _get_eval_string(item, true)))
+ end
+ alias item_num_children item_numchildren
+ alias item_children_size item_numchildren
+
+ def item_order(item, visible=false)
+ if visible
+ ret = num_or_str(tk_send('item', 'order', item, '-visible'))
+ else
+ ret = num_or_str(tk_send('item', 'order', item))
+ end
+
+ (ret.kind_of?(Fixnum) && ret < 0)? nil: ret
+ end
+ def item_visible_order(item)
+ item_order(item, true)
+ end
+
+ def item_parent(item)
+ id = num_or_str(tk_send('item', 'parent', item))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+
+ def item_prevsibling(sibling, prev=nil)
+ if prev
+ tk_send('item', 'prevsibling', sibling, prev)
+ self
+ else
+ id = num_or_str(tk_send('item', 'prevsibling', sibling))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_prev_sibling item_prevsibling
+
+ def item_range(first, last)
+ simplelist(tk_send('item', 'range', first, last))
+ end
+
+ def item_remove(item)
+ tk_send('item', 'remove', item)
+ self
+ end
+
+ def item_rnc(item)
+ list(tk_send('item', 'rnc', item))
+ end
+
+ def _item_sort_core(real_sort, item, *opts)
+ # opts ::= sort_param [, sort_param, ... ]
+ # sort_param ::= {key=>val, ...}
+ # [type, desc, {key=>val, ...}]
+ # param
+ opts = opts.collect{|param|
+ if param.kind_of?(Hash)
+ param = _symbolkey2str(param)
+ if param.key?('column')
+ key = '-column'
+ desc = param.delete('column')
+ elsif param.key?('element')
+ key = '-element'
+ desc = param.delete('element')
+ else
+ key = nil
+ end
+
+ if param.empty?
+ param = None
+ else
+ param = hash_kv(__conv_item_keyonly_opts(item, param))
+ end
+
+ if key
+ [key, desc].concat(param)
+ else
+ param
+ end
+
+ elsif param.kind_of?(Array)
+ if param[2].kind_of?(Hash)
+ param[2] = hash_kv(__conv_item_keyonly_opts(item, param[2]))
+ end
+ param
+
+ elsif param.kind_of?(String) && param =~ /\A[a-z]+\Z/
+ '-' << param
+
+ elsif param.kind_of?(Symbol)
+ '-' << param.to_s
+
+ else
+ param
+ end
+ }.flatten
+
+ if real_sort
+ tk_send('item', 'sort', item, *opts)
+ self
+ else
+ list(tk_send('item', 'sort', item, '-notreally', *opts))
+ end
+ end
+ private :_item_sort_core
+
+ def item_sort(item, *opts)
+ _item_sort_core(true, item, *opts)
+ end
+ def item_sort_not_really(item, *opts)
+ _item_sort_core(false, item, *opts)
+ end
+
+ def item_span(item, column=nil, *args)
+ if args.empty?
+ if column
+ list(tk_send('item', 'span', item, column))
+ else
+ simplelist(tk_send('item', 'span', item)).collect!{|elem| list(elem)}
+ end
+ else
+ tk_send('item', 'span', item, column, *args)
+ self
+ end
+ end
+ def get_item_span(item, column=nil)
+ item_span(item, column)
+ end
+ def set_item_span(item, col, num, *args)
+ item_span(item, col, num, *args)
+ end
+
+ def item_state_forcolumn(item, column, *args)
+ tk_send('item', 'state', 'forcolumn', item, column, *args)
+ end
+ alias item_state_for_column item_state_forcolumn
+
+ def item_state_get(item, *args)
+ if args.empty?
+ list(tk_send('item', 'state', 'get', item *args))
+ else
+ bool(tk_send('item', 'state', 'get', item))
+ end
+ end
+
+ def item_state_set(item, *args)
+ tk_send('item', 'state', 'set', item, *args)
+ end
+
+ def item_style_elements(item, column)
+ list(tk_send('item', 'style', 'elements', item, column)).collect!{|id|
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ }
+ end
+
+ def item_style_map(item, column, style, map)
+ tk_send('item', 'style', 'map', item, column, style, map)
+ self
+ end
+
+ def item_style_set(item, column=nil, *args)
+ if args.empty?
+ if column
+ id = tk_send_without_enc('item', 'style', 'set',
+ _get_eval_string(item, true),
+ _get_eval_string(column, true))
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ else
+ list(tk_send_without_enc('item', 'style', 'set',
+ _get_eval_string(item, true))).collect!{|id|
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ }
+ end
+ else
+ tk_send_without_enc('item', 'style', 'set',
+ _get_eval_string(item, true),
+ _get_eval_string(column, true),
+ *(args.flatten.map!{|arg|
+ _get_eval_string(arg, true)
+ }))
+ self
+ end
+ end
+
+ def item_text(item, column, txt=nil, *args)
+ if args.empty?
+ if txt
+ tk_send('item', 'text', item, column, txt)
+ self
+ else
+ tk_send('item', 'text', item, column)
+ end
+ else
+ tk_send('item', 'text', item, column, txt, *args)
+ self
+ end
+ end
+
+ def item_toggle(item)
+ tk_send('item', 'toggle', item)
+ self
+ end
+
+ def item_toggle_recurse(item)
+ tk_send('item', 'toggle', item, '-recurse')
+ self
+ end
+
+ def item_visible(item, st=None)
+ if st == None
+ bool(tk_send('item', 'visible', item))
+ else
+ tk_send('item', 'visible', item, st)
+ self
+ end
+ end
+ def item_visible?(item)
+ item_visible(item)
+ end
+
+ def marquee_anchor(*args)
+ if args.empty?
+ list(tk_send('marquee', 'anchor'))
+ else
+ tk_send('marquee', 'anchor', *args)
+ self
+ end
+ end
+
+ def marquee_coords(*args)
+ if args.empty?
+ list(tk_send('marquee', 'coords'))
+ else
+ tk_send('marquee', 'coords', *args)
+ self
+ end
+ end
+
+ def marquee_corner(*args)
+ if args.empty?
+ tk_send('marquee', 'corner')
+ else
+ tk_send('marquee', 'corner', *args)
+ self
+ end
+ end
+
+ def marquee_identify()
+ list(tk_send('marquee', 'identify')).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def marquee_visible(st=None)
+ if st == None
+ bool(tk_send('marquee', 'visible'))
+ else
+ tk_send('marquee', 'visible', st)
+ self
+ end
+ end
+ def marquee_visible?()
+ marquee_visible()
+ end
+
+ #def notify_bind(obj, event, cmd=Proc.new, *args)
+ # _bind([@path, 'notify', 'bind', obj], event, cmd, *args)
+ # self
+ #end
+ def notify_bind(obj, event, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'notify', 'bind', obj], event, cmd, *args)
+ self
+ end
+
+ #def notify_bind_append(obj, event, cmd=Proc.new, *args)
+ # _bind_append([@path, 'notify', 'bind', obj], event, cmd, *args)
+ # self
+ #end
+ def notify_bind_append(obj, event, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'notify', 'bind', obj], event, cmd, *args)
+ self
+ end
+
+ def notify_bind_remove(obj, event)
+ _bind_remove([@path, 'notify', 'bind', obj], event)
+ self
+ end
+
+ def notify_bindinfo(obj, event=nil)
+ _bindinfo([@path, 'notify', 'bind', obj], event)
+ end
+
+ def notify_detailnames(event)
+ list(tk_send('notify', 'detailnames', event))
+ end
+
+ def notify_eventnames()
+ list(tk_send('notify', 'eventnames'))
+ end
+
+ def notify_generate(pattern, char_map=None, percents_cmd=None)
+ pattern = "<#{pattern}>"
+ tk_send('notify', 'generate', pattern, char_map, percents_cmd)
+ self
+ end
+
+ def notify_install(pattern, percents_cmd=nil, &b)
+ pattern = "<#{pattern}>"
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ procedure(tk_send('notify', 'install', pattern, percents_cmd))
+ else
+ procedure(tk_send('notify', 'install', pattern))
+ end
+ end
+
+ def notify_install_detail(event, detail, percents_cmd=nil, &b)
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ tk_send('notify', 'install', 'detail', event, detail, percents_cmd)
+ else
+ tk_send('notify', 'install', 'detail', event, detail)
+ end
+ end
+
+ def notify_install_event(event, percents_cmd=nil, &b)
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ tk_send('notify', 'install', 'event', event, percents_cmd)
+ else
+ tk_send('notify', 'install', 'event', event)
+ end
+ end
+
+ def notify_linkage(pattern, detail=None)
+ if detail != None
+ tk_send('notify', 'linkage', pattern, detail)
+ else
+ begin
+ if pattern.to_s.index(?-)
+ # TreeCtrl 1.1 format?
+ begin
+ tk_send('notify', 'linkage', "<#{pattern}>")
+ rescue
+ # TreeCtrl 1.0?
+ tk_send('notify', 'linkage', pattern)
+ end
+ else
+ # TreeCtrl 1.0 format?
+ begin
+ tk_send('notify', 'linkage', pattern)
+ rescue
+ # TreeCtrl 1.1?
+ tk_send('notify', 'linkage', "<#{pattern}>")
+ end
+ end
+ end
+ end
+ end
+
+ def notify_unbind(pattern=nil)
+ if pattern
+ tk_send('notify', 'unbind', "<#{pattern}>")
+ else
+ tk_send('notify', 'unbind')
+ end
+ self
+ end
+
+ def notify_uninstall(pattern)
+ pattern = "<#{pattern}>"
+ tk_send('notify', 'uninstall', pattern)
+ self
+ end
+
+ def notify_uninstall_detail(event, detail)
+ tk_send('notify', 'uninstall', 'detail', event, detail)
+ self
+ end
+
+ def notify_uninstall_event(event)
+ tk_send('notify', 'uninstall', 'event', event)
+ self
+ end
+
+ def numcolumns()
+ num_or_str(tk_send('numcolumns'))
+ end
+ alias num_columns numcolumns
+ alias columns_size numcolumns
+
+ def numitems()
+ num_or_str(tk_send('numitems'))
+ end
+ alias num_items numitems
+ alias items_size numitems
+
+ def orphans()
+ list(tk_send('orphans')).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def range(first, last)
+ list(tk_send('range', first, last)).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def state_define(name)
+ tk_send('state', 'define', name)
+ self
+ end
+
+ def state_linkage(name)
+ tk_send('state', 'linkage', name)
+ end
+
+ def state_names()
+ list(tk_send('state', 'names'))
+ end
+
+ def state_undefine(*names)
+ tk_send('state', 'undefine', *names)
+ self
+ end
+
+ def see(item, column=None, keys={})
+ tk_send('see', item, column, *hash_kv(keys))
+ self
+ end
+
+ def selection_add(first, last=None)
+ tk_send('selection', 'add', first, last)
+ self
+ end
+
+ def selection_anchor(item=None)
+ id = num_or_str(tk_send('selection', 'anchor', item))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+
+ def selection_clear(*args) # first, last
+ tk_send('selection', 'clear', *args)
+ self
+ end
+
+ def selection_count()
+ number(tk_send('selection', 'count'))
+ end
+
+ def selection_get()
+ list(tk_send('selection', 'get')).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def selection_includes(item)
+ bool(tk_send('selection', 'includes', item))
+ end
+
+ def selection_modify(sel, desel)
+ tk_send('selection', 'modify', sel, desel)
+ self
+ end
+
+ def style_create(style, keys=None)
+ if keys && keys != None
+ tk_send('style', 'create', style, *hash_kv(keys))
+ else
+ tk_send('style', 'create', style)
+ end
+ end
+
+ def style_delete(*args)
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
+ args.each{|sty|
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
+ }
+ end
+ }
+ tk_send('style', 'delete', *args)
+ self
+ end
+
+ def style_elements(style, *elems)
+ if elems.empty?
+ list(tk_send('style', 'elements', style)).collect!{|id|
+ Tk::TreeCtrl::Element.id2obj(self, id)
+ }
+ else
+ tk_send('style', 'elements', style, elems.flatten)
+ self
+ end
+ end
+
+ def _conv_style_layout_val(sty, val)
+ case sty.to_s
+ when 'padx', 'pady', 'ipadx', 'ipady'
+ lst = list(val)
+ (lst.size == 1)? lst[0]: lst
+ when 'detach', 'indent'
+ bool(val)
+ when 'union'
+ simplelist(val).collect!{|elem|
+ Tk::TreeCtrl::Element.id2obj(self, elem)
+ }
+ else
+ val
+ end
+ end
+ private :_conv_style_layout_val
+
+ def style_layout(style, elem, keys=None)
+ if keys && keys != None
+ if keys.kind_of?(Hash)
+ tk_send('style', 'layout', style, elem, *hash_kv(keys))
+ self
+ else
+ _conv_style_layout_val(keys,
+ tk_send('style', 'layout',
+ style, elem, "-#{keys}"))
+ end
+ else
+ ret = Hash.new
+ Hash[*simplelist(tk_send('style', 'layout', style, elem))].each{|k, v|
+ k = k[1..-1]
+ ret[k] = _conv_style_layout_val(k, v)
+ }
+ ret
+ end
+ end
+ def get_style_layout(style, elem, opt=None)
+ style_layout(style, elem, opt)
+ end
+ def set_style_layout(style, elem, slot, value=None)
+ if slot.kind_of?(Hash)
+ style_layout(style, elem, slot)
+ else
+ style_layout(style, elem, {slot=>value})
+ end
+ end
+
+ def style_names()
+ list(tk_send('style', 'names')).collect!{|id|
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ }
+ end
+
+ def toggle(*items)
+ tk_send('toggle', *items)
+ self
+ end
+
+ def toggle_recurse()
+ tk_send('toggle', '-recurse', *items)
+ self
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Column < TkObject
+ TreeCtrlColumnID_TBL = TkCore::INTERP.create_table
+
+ (TreeCtrlColumnID = ['treectrl_column'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys={})
+ @tree = parent
+ @tpath = parent.path
+
+ keys = _symbolkey2str(keys)
+
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.mutex.synchronize{
+ @path = @id =
+ keys.delete('tag') ||
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
+ }
+
+ keys['tag'] = @id
+
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
+ }
+
+ @tree.column_create(keys)
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.to_s.dup
+ end
+
+ def cget_tkstring(opt)
+ @tree.column_cget_tkstring(@tree.column_index(@id), opt)
+ end
+ def cget(opt)
+ @tree.column_cget(@tree.column_index(@id), opt)
+ end
+ def cget_strict(opt)
+ @tree.column_cget_strict(@tree.column_index(@id), opt)
+ end
+
+ def configure(*args)
+ @tree.column_configure(@tree.column_index(@id), *args)
+ end
+
+ def configinfo(*args)
+ @tree.column_configinfo(@tree.column_index(@id), *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_column_configinfo(@tree.column_index(@id), *args)
+ end
+
+ def delete
+ @tree.column_delete(@tree.column_index(@id))
+ self
+ end
+
+ def index
+ @tree.column_index(@id)
+ end
+
+ def move(before)
+ @tree.column_move(@tree.column_index(@id), before)
+ self
+ end
+
+ def needed_width
+ @tree.column_needed_width(@tree.column_index(@id))
+ end
+ alias neededwidth needed_width
+
+ def current_width
+ @tree.column_width(@tree.column_index(@id))
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Element < TkObject
+ TreeCtrlElementID_TBL = TkCore::INTERP.create_table
+
+ (TreeCtrlElementID = ['treectrl_element'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TreeCtrlElemTypeToClass = {}
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
+ }
+ }
+
+ def self.type2class(type)
+ TreeCtrlElemTypeToClass[type] || type
+ end
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, type, keys=nil)
+ @tree = parent
+ @tpath = parent.path
+ @type = type.to_s
+ Tk::TreeCtrl::Element::TreeCtrlElementID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
+ }
+
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
+ }
+
+ @tree.element_create(@id, @type, keys)
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.dup
+ end
+
+ def cget_tkstring(opt)
+ @tree.element_cget_tkstring(@id, opt)
+ end
+ def cget(opt)
+ @tree.element_cget(@id, opt)
+ end
+ def cget_strict(opt)
+ @tree.element_cget_strict(@id, opt)
+ end
+
+ def configure(*args)
+ @tree.element_configure(@id, *args)
+ end
+
+ def configinfo(*args)
+ @tree.element_configinfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_element_configinfo(@id, *args)
+ end
+
+ def delete
+ @tree.element_delete(@id)
+ self
+ end
+
+ def element_type
+ @tree.element_type(@id)
+ end
+
+ def element_class
+ @tree.element_class(@id)
+ end
+end
+
+class Tk::TreeCtrl::BitmapElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['bitmap'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'bitmap', keys)
+ end
+end
+
+class Tk::TreeCtrl::BorderElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['border'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'border', keys)
+ end
+end
+
+class Tk::TreeCtrl::ImageElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['image'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'image', keys)
+ end
+end
+
+class Tk::TreeCtrl::RectangleElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['rect'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'rect', keys)
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Item < TkObject
+ TreeCtrlItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys={})
+ @tree = parent
+ @tpath = parent.path
+ @path = @id = @tree.item_create(keys)
+
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.to_s.dup
+ end
+
+ def ancestors
+ @tree.item_ancestors(@id)
+ end
+
+ def bbox(*args)
+ @tree.item_bbox(@id, *args)
+ end
+
+ def children
+ @tree.item_children(@id)
+ end
+
+ def collapse
+ @tree.item_collapse(@id)
+ self
+ end
+
+ def collapse_recurse
+ @tree.item_collapse_recurse(@id)
+ self
+ end
+
+ def complex(*args)
+ @tree.item_complex(@id, *args)
+ self
+ end
+
+ def cget_tkstring(opt)
+ @tree.item_cget_tkstring(@id, opt)
+ end
+ def cget(opt)
+ @tree.item_cget(@id, opt)
+ end
+ def cget_strict(opt)
+ @tree.item_cget_strict(@id, opt)
+ end
+
+ def configure(*args)
+ @tree.item_configure(@id, *args)
+ end
+
+ def configinfo(*args)
+ @tree.item_configinfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_item_configinfo(@id, *args)
+ end
+
+ def delete
+ @tree.item_delete(@id)
+ self
+ end
+
+ def element_dump
+ @tree.item_dump(@id)
+ end
+
+ def element_dump_hash
+ @tree.item_dump_hash(@id)
+ end
+
+ def element_actual(column, elem, key)
+ @tree.item_element_actual(@id, column, elem, key)
+ end
+
+ def element_cget_tkstring(opt)
+ @tree.item_element_cget(@id, opt)
+ end
+ def element_cget_tkstring(opt)
+ @tree.item_element_cget(@id, opt)
+ end
+ def element_cget_strict(opt)
+ @tree.item_element_cget_strict(@id, opt)
+ end
+
+ def element_configure(*args)
+ @tree.item_element_configure(@id, *args)
+ end
+
+ def element_configinfo(*args)
+ @tree.item_element_configinfo(@id, *args)
+ end
+
+ def current_element_configinfo(*args)
+ @tree.current_item_element_configinfo(@id, *args)
+ end
+
+ def expand
+ @tree.item_expand(@id)
+ self
+ end
+
+ def expand_recurse
+ @tree.item_expand_recurse(@id)
+ self
+ end
+
+ def firstchild(child=nil)
+ if child
+ @tree.item_firstchild(@id, child)
+ self
+ else
+ @tree.item_firstchild(@id)
+ end
+ end
+ alias first_child firstchild
+
+ def hasbutton(st=None)
+ if st == None
+ @tree.item_hasbutton(@id)
+ else
+ @tree.item_hasbutton(@id, st)
+ self
+ end
+ end
+ alias has_button hasbutton
+
+ def hasbutton?
+ @tree.item_hasbutton(@id)
+ end
+ alias has_button? hasbutton?
+
+ def index
+ @tree.item_index(@id)
+ end
+
+ def isancestor(des)
+ @tree.item_isancestor(@id, des)
+ end
+ alias is_ancestor isancestor
+ alias isancestor? isancestor
+ alias is_ancestor? isancestor
+ alias ancestor? isancestor
+
+ def isopen
+ @tree.item_isopen(@id)
+ end
+ alias is_open isopen
+ alias isopen? isopen
+ alias is_open? isopen
+ alias isopened? isopen
+ alias is_opened? isopen
+ alias open? isopen
+
+ def lastchild(child=nil)
+ if child
+ @tree.item_lastchild(@id, child)
+ self
+ else
+ @tree.item_lastchild(@id)
+ end
+ end
+ alias last_child lastchild
+
+ def nextsibling(nxt=nil)
+ if nxt
+ @tree.item_nextsibling(@id, nxt)
+ self
+ else
+ @tree.item_nextsibling(@id)
+ end
+ end
+ alias next_sibling nextsibling
+
+ def numchildren
+ @tree.item_numchildren(@id)
+ end
+ alias num_children numchildren
+ alias children_size numchildren
+
+ def parent_index
+ @tree.item_parent(@id)
+ end
+
+ def prevsibling(nxt=nil)
+ if nxt
+ @tree.item_prevsibling(@id, nxt)
+ self
+ else
+ @tree.item_prevsibling(@id)
+ end
+ end
+ alias prev_sibling prevsibling
+
+ def remove
+ @tree.item_remove(@id)
+ end
+
+ def rnc
+ @tree.item_rnc(@id)
+ end
+
+ def sort(*opts)
+ @tree.item_sort(@id, *opts)
+ end
+ def sort_not_really(*opts)
+ @tree.item_sort_not_really(@id, *opts)
+ self
+ end
+
+ def state_forcolumn(column, *args)
+ @tree.item_state_forcolumn(@id, column, *args)
+ self
+ end
+ alias state_for_column state_forcolumn
+
+ def state_get(*args)
+ @tree.item_state_get(@id, *args)
+ end
+
+ def state_set(*args)
+ @tree.item_state_set(@id, *args)
+ self
+ end
+
+ def style_elements(column)
+ @tree.item_style_elements(@id, column)
+ end
+
+ def style_map(column, style, map)
+ @tree.item_style_map(@id, column, style, map)
+ self
+ end
+
+ def style_set(column=nil, *args)
+ if args.empty?
+ @tree.item_style_set(@id, column)
+ else
+ @tree.item_style_set(@id, column, *args)
+ self
+ end
+ end
+
+ def item_text(column, txt=nil, *args)
+ if args.empty?
+ if txt
+ @tree.item_text(@id, column, txt)
+ self
+ else
+ @tree.item_text(@id, column)
+ end
+ else
+ @tree.item_text(@id, column, txt, *args)
+ self
+ end
+ end
+
+ def toggle
+ @tree.item_toggle(@id)
+ self
+ end
+
+ def toggle_recurse
+ @tree.item_toggle_recurse(@id)
+ self
+ end
+
+ def visible(st=None)
+ if st == None
+ @tree.item_visible(@id)
+ else
+ @tree.item_visible(@id, st)
+ self
+ end
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Style < TkObject
+ TreeCtrlStyleID_TBL = TkCore::INTERP.create_table
+
+ (TreeCtrlStyleID = ['treectrl_style'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys=nil)
+ @tree = parent
+ @tpath = parent.path
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
+ }
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
+ }
+
+ @tree.style_create(@id, keys)
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.dup
+ end
+
+ def cget_tkstring(opt)
+ @tree.style_cget_tkstring(@id, opt)
+ end
+ def cget(opt)
+ @tree.style_cget(@id, opt)
+ end
+ def cget_strict(opt)
+ @tree.style_cget_strict(@id, opt)
+ end
+
+ def configure(*args)
+ @tree.style_configure(@id, *args)
+ end
+
+ def configinfo(*args)
+ @tree.style_configinfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_style_configinfo(@id, *args)
+ end
+
+ def delete
+ @tree.style_delete(@id)
+ self
+ end
+
+ def elements(*elems)
+ if elems.empty?
+ @tree.style_elements(@id)
+ else
+ @tree.style_elements(@id, *elems)
+ self
+ end
+ end
+
+ def layout(elem, keys=None)
+ if keys && keys != None && keys.kind_of?(Hash)
+ @tree.style_layout(@id, elem, keys)
+ self
+ else
+ @tree.style_layout(@id, elem, keys)
+ end
+ end
+end
+
+module Tk::TreeCtrl::BindCallback
+ include Tk
+ extend Tk
+end
+
+class << Tk::TreeCtrl::BindCallback
+ def percentsCmd(*args)
+ tk_call('::TreeCtrl::PercentsCmd', *args)
+ end
+ def cursorCheck(w, x, y)
+ tk_call('::TreeCtrl::CursorCheck', w, x, y)
+ end
+ def cursorCheckAux(w)
+ tk_call('::TreeCtrl::CursorCheckAux', w)
+ end
+ def cursorCancel(w)
+ tk_call('::TreeCtrl::CursorCancel', w)
+ end
+ def buttonPress1(w, x, y)
+ tk_call('::TreeCtrl::ButtonPress1', w, x, y)
+ end
+ def doubleButton1(w, x, y)
+ tk_call('::TreeCtrl::DoubleButton1', w, x, y)
+ end
+ def motion1(w, x, y)
+ tk_call('::TreeCtrl::Motion1', w, x, y)
+ end
+ def leave1(w, x, y)
+ tk_call('::TreeCtrl::Leave1', w, x, y)
+ end
+ def release1(w, x, y)
+ tk_call('::TreeCtrl::Release1', w, x, y)
+ end
+ def beginSelect(w, el)
+ tk_call('::TreeCtrl::BeginSelect', w, el)
+ end
+ def motion(w, le)
+ tk_call('::TreeCtrl::Motion', w, el)
+ end
+ def beginExtend(w, el)
+ tk_call('::TreeCtrl::BeginExtend', w, el)
+ end
+ def beginToggle(w, el)
+ tk_call('::TreeCtrl::BeginToggle', w, el)
+ end
+ def cancelRepeat
+ tk_call('::TreeCtrl::CancelRepeat')
+ end
+ def autoScanCheck(w, x, y)
+ tk_call('::TreeCtrl::AutoScanCheck', w, x, y)
+ end
+ def autoScanCheckAux(w)
+ tk_call('::TreeCtrl::AutoScanCheckAux', w)
+ end
+ def autoScanCancel(w)
+ tk_call('::TreeCtrl::AutoScanCancel', w)
+ end
+ def up_down(w, n)
+ tk_call('::TreeCtrl::UpDown', w, n)
+ end
+ def left_right(w, n)
+ tk_call('::TreeCtrl::LeftRight', w, n)
+ end
+ def setActiveItem(w, idx)
+ tk_call('::TreeCtrl::SetActiveItem', w, idx)
+ end
+ def extendUpDown(w, amount)
+ tk_call('::TreeCtrl::ExtendUpDown', w, amount)
+ end
+ def dataExtend(w, el)
+ tk_call('::TreeCtrl::DataExtend', w, el)
+ end
+ def cancel(w)
+ tk_call('::TreeCtrl::Cancel', w)
+ end
+ def selectAll(w)
+ tk_call('::TreeCtrl::selectAll', w)
+ end
+ def marqueeBegin(w, x, y)
+ tk_call('::TreeCtrl::MarqueeBegin', w, x, y)
+ end
+ def marqueeUpdate(w, x, y)
+ tk_call('::TreeCtrl::MarqueeUpdate', w, x, y)
+ end
+ def marqueeEnd(w, x, y)
+ tk_call('::TreeCtrl::MarqueeEnd', w, x, y)
+ end
+ def scanMark(w, x, y)
+ tk_call('::TreeCtrl::ScanMark', w, x, y)
+ end
+ def scanDrag(w, x, y)
+ tk_call('::TreeCtrl::ScanDrag', w, x, y)
+ end
+
+ # filelist-bindings
+ def fileList_button1(w, x, y)
+ tk_call('::TreeCtrl::FileListButton1', w, x, y)
+ end
+ def fileList_motion1(w, x, y)
+ tk_call('::TreeCtrl::FileListMotion1', w, x, y)
+ end
+ def fileList_motion(w, x, y)
+ tk_call('::TreeCtrl::FileListMotion', w, x, y)
+ end
+ def fileList_leave1(w, x, y)
+ tk_call('::TreeCtrl::FileListLeave1', w, x, y)
+ end
+ def fileList_release1(w, x, y)
+ tk_call('::TreeCtrl::FileListRelease1', w, x, y)
+ end
+ def fileList_edit(w, i, s, e)
+ tk_call('::TreeCtrl::FileListEdit', w, i, s, e)
+ end
+ def fileList_editCancel(w)
+ tk_call('::TreeCtrl::FileListEditCancel', w)
+ end
+ def fileList_autoScanCheck(w, x, y)
+ tk_call('::TreeCtrl::FileListAutoScanCheck', w, x, y)
+ end
+ def fileList_autoScanCheckAux(w)
+ tk_call('::TreeCtrl::FileListAutoScanCheckAux', w)
+ end
+
+ def entryOpen(w, item, col, elem)
+ tk_call('::TreeCtrl::EntryOpen', w, item, col, elem)
+ end
+ def entryExpanderOpen(w, item, col, elem)
+ tk_call('::TreeCtrl::EntryExpanderOpen', w, item, col, elem)
+ end
+ def entryClose(w, accept)
+ tk_call('::TreeCtrl::EntryClose', w, accept)
+ end
+ def entryExpanderKeypress(w)
+ tk_call('::TreeCtrl::EntryExpanderKeypress', w)
+ end
+ def textOpen(w, item, col, elem, width=0, height=0)
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width, height)
+ end
+ def textExpanderOpen(w, item, col, elem, width)
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width)
+ end
+ def textClose(w, accept)
+ tk_call('::TreeCtrl::TextClose', w, accept)
+ end
+ def textExpanderKeypress(w)
+ tk_call('::TreeCtrl::TextExpanderKeypress', w)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/trofs.rb b/jni/ruby/ext/tk/lib/tkextlib/trofs.rb
new file mode 100644
index 0000000..5914e51
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/trofs.rb
@@ -0,0 +1,13 @@
+#
+# trofs support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/trofs/setup.rb'
+
+# load library
+require 'tkextlib/trofs/trofs.rb'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb b/jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb
new file mode 100644
index 0000000..7a2606a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb
@@ -0,0 +1,51 @@
+#
+# tkextlib/trofs/trofs.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/trofs/setup.rb'
+
+# TkPackage.require('trofs', '0.4')
+TkPackage.require('trofs')
+
+module Tk
+ module Trofs
+ extend TkCore
+
+ PACKAGE_NAME = 'trofs'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('trofs')
+ rescue
+ ''
+ end
+ end
+
+ ##############################################
+
+ def self.create_archive(dir, archive)
+ tk_call('::trofs::archive', dir, archive)
+ archive
+ end
+
+ def self.mount(archive, mountpoint=None)
+ # returns the normalized path to mountpoint
+ tk_call('::trofs::mount', archive, mountpoint)
+ end
+
+ def self.umount(mountpoint)
+ tk_call('::trofs::umount', mountpoint)
+ mountpoint
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/version.rb b/jni/ruby/ext/tk/lib/tkextlib/version.rb
new file mode 100644
index 0000000..4bef78f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/version.rb
@@ -0,0 +1,6 @@
+#
+# release date of tkextlib
+#
+module Tk
+ Tkextlib_RELEASE_DATE = '2010-02-01'.freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu.rb b/jni/ruby/ext/tk/lib/tkextlib/vu.rb
new file mode 100644
index 0000000..d2234eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu.rb
@@ -0,0 +1,48 @@
+#
+# The vu widget set support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/vu/setup.rb'
+
+# load package
+# TkPackage.require('vu', '2.1')
+TkPackage.require('vu')
+
+# autoload
+module Tk
+ module Vu
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ PACKAGE_NAME = 'vu'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('vu')
+ rescue
+ ''
+ end
+ end
+
+ ##########################################
+
+ autoload :Dial, 'tkextlib/vu/dial'
+
+ autoload :Pie, 'tkextlib/vu/pie'
+ autoload :PieSlice, 'tkextlib/vu/pie'
+ autoload :NamedPieSlice, 'tkextlib/vu/pie'
+
+ autoload :Spinbox, 'tkextlib/vu/spinbox'
+
+ autoload :Bargraph, 'tkextlib/vu/bargraph'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb
new file mode 100644
index 0000000..b9fcf92
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb
@@ -0,0 +1,61 @@
+#
+# ::vu::bargraph widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ class Bargraph < TkWindow
+ end
+ end
+end
+
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+class Tk::Vu::Bargraph < TkWindow
+ TkCommandNames = ['::vu::bargraph'.freeze].freeze
+ WidgetClassName = 'Bargraph'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ###############################
+
+ def __boolval_optkeys
+ ['showminmax', 'showvalue']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() + [
+ 'title',
+ 'barbackground', 'barcolor', 'barcolour',
+ 'tickcolor', 'tickcolour',
+ 'textcolor', 'textcolour',
+ ]
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ ['alabels', 'blabels']
+ end
+ private :__listval_optkeys
+
+ def __font_optkeys
+ ['alabfont', 'blabfont']
+ end
+ private :__font_optkeys
+
+ ###############################
+
+ def set(val = None)
+ tk_call_without_enc(@path, 'set', val)
+ self
+ end
+
+ def get()
+ num_or_str(tk_call_without_enc(@path, 'get'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb
new file mode 100644
index 0000000..8569ac5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb
@@ -0,0 +1,53 @@
+#
+# charts -- Create and manipulate canvas Add-On Items
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tk/canvas'
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+module Tk
+ module Vu
+ module ChartsConfig
+ include TkItemConfigOptkeys
+ def __item_boolval_optkeys(id)
+ super(id) << 'lefttrunc' << 'autocolor'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ super(id) << 'bar' << 'color' << 'outline' <<
+ 'fill' << 'scaleline' << 'stripline'
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ super(id) << 'values' << 'tags'
+ end
+ private :__item_listval_optkeys
+ end
+
+ class TkcSticker < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'sticker'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+
+ class TkcStripchart < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'stripchart'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+
+ class TkcBarchart < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'barchart'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb
new file mode 100644
index 0000000..4d04974
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb
@@ -0,0 +1,102 @@
+#
+# ::vu::dial widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ class Dial < TkWindow
+ end
+ end
+end
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+# define module/class
+class Tk::Vu::Dial < TkWindow
+ TkCommandNames = ['::vu::dial'.freeze].freeze
+ WidgetClassName = 'Dial'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ###############################
+
+ def __methodcall_optkeys # { key=>method, ... }
+ {'coords'=>'coords'}
+ end
+ private :__methodcall_optkeys
+
+ ###############################
+
+ def coords(val = nil)
+ if val
+ tk_send_without_enc('coords', val)
+ self
+ else
+ tk_split_list(tk_send_without_enc('coords'))
+ end
+ end
+
+ def constrain(val = None)
+ num_or_str(tk_call(@path, 'constrain', val))
+ end
+
+ def get(*args)
+ num_or_str(tk_call(@path, 'get', *args))
+ end
+
+ def identify(x, y)
+ tk_call(@path, 'identify', x, y)
+ end
+
+ def get_label(val=nil)
+ if val
+ tk_call(@path, 'label', val)
+ else
+ ret = []
+ lst = simplelist(tk_call(@path, 'label'))
+ while lst.size > 0
+ ret << ([num_or_str(lst.shift)] << lst.shift)
+ end
+ end
+ end
+
+ def set_label(val, str, *args)
+ tk_call(@path, 'label', val, str, *args)
+ self
+ end
+
+ def set_label_constrain(val, str, *args)
+ tk_call(@path, 'label', '-constrain', val, str, *args)
+ self
+ end
+
+ def get_tag(val=nil)
+ if val
+ tk_call(@path, 'tag', val)
+ else
+ ret = []
+ lst = simplelist(tk_call(@path, 'tag'))
+ while lst.size > 0
+ ret << ([num_or_str(lst.shift)] << lst.shift)
+ end
+ end
+ end
+
+ def set_tag(val, str, *args)
+ tk_call(@path, 'tag', val, str, *args)
+ self
+ end
+
+ def set_tag_constrain(val, str, *args)
+ tk_call(@path, 'tag', '-constrain', val, str, *args)
+ self
+ end
+
+ def set(val = None)
+ tk_call_without_enc(@path, 'set', val)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb
new file mode 100644
index 0000000..6b0c485
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb
@@ -0,0 +1,286 @@
+#
+# ::vu::pie widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ module PieSliceConfigMethod
+ end
+ class Pie < TkWindow
+ end
+ class PieSlice < TkObject
+ end
+ class NamedPieSlice < PieSlice
+ end
+ end
+end
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+module Tk::Vu::PieSliceConfigMethod
+ include TkItemConfigMethod
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(Tk::Vu::PieSlice)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+end
+
+class Tk::Vu::Pie < TkWindow
+ TkCommandNames = ['::vu::pie'.freeze].freeze
+ WidgetClassName = 'Pie'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ Tk::Vu::PieSlice::SliceID_TBL.delete(@path)
+ end
+
+ ###############################
+
+ include Tk::Vu::PieSliceConfigMethod
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Vu::PieSlice)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ ###############################
+
+ def delete(*glob_pats)
+ tk_call(@path, 'delete', *glob_pats)
+ self
+ end
+
+ def explode(slice, *args)
+ tk_call(@path, 'explode', slice, *args)
+ self
+ end
+
+ def explode_value(slice)
+ num_or_str(tk_call(@path, 'explode', slice))
+ end
+
+ def lower(slice, below=None)
+ tk_call(@path, 'lower', slice, below)
+ self
+ end
+
+ def names(*glob_pats)
+ simplelist(tk_call(@path, 'names', *glob_pats))
+ end
+ alias slices names
+
+ def order(*args)
+ tk_call(@path, 'order', *args)
+ self
+ end
+
+ def raise(slice, above=None)
+ tk_call(@path, 'raise', slice, above)
+ self
+ end
+
+ def swap(slice1, slice2)
+ tk_call(@path, 'swap', slice1, slice2)
+ self
+ end
+
+ def set(slice, *args)
+ num_or_str(tk_call(@path, 'set', slice, *args))
+ end
+ alias set_value set
+ alias set_values set
+ alias create set
+
+ def slice_value(slice)
+ num_or_str(tk_call(@path, 'set', slice))
+ end
+
+ def value(val = None)
+ num_or_str(tk_call_without_enc(@path, 'value'))
+ end
+ alias sum_value value
+end
+
+class Tk::Vu::PieSlice
+ SliceID_TBL = TkCore::INTERP.create_table
+
+ (Pie_Slice_ID = ['vu:pie'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ SliceID_TBL.mutex.synchronize{ SliceID_TBL.clear }
+ }
+
+ def self.id2obj(pie, id)
+ pie_path = pie.path
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[pie_path]
+ SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ @parent = @pie = parent
+ @ppath = parent.path
+ Pie_Slice_ID.mutex.synchronize{
+ @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
+ Pie_Slice_ID[1].succ!
+ }
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget_tkstring(slot)
+ @pie.itemcget_tkstring(@id, slot)
+ end
+
+ def cget(slot)
+ @pie.itemcget(@id, slot)
+ end
+
+ def cget_strict(slot)
+ @pie.itemcget_strict(@id, slot)
+ end
+
+ def configure(*args)
+ @pie.itemconfigure(@id, *args)
+ self
+ end
+
+ def configinfo(*args)
+ @pie.itemconfiginfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @pie.current_itemconfiginfo(@id, *args)
+ end
+
+ def delete
+ @pie.delete(@id)
+ end
+
+ def explode(value)
+ @pie.explode(@id, value)
+ self
+ end
+
+ def explode_value
+ @pie.explode_value(@id)
+ end
+
+ def lower(other=None)
+ @pie.lower(@id, other)
+ self
+ end
+
+ def raise(other=None)
+ @pie.raise(@id, other)
+ self
+ end
+
+ def set(value)
+ @pie.set(@id, value)
+ self
+ end
+ alias set_value set
+
+ def value
+ @pie.set(@id)
+ end
+end
+
+class Tk::Vu::NamedPieSlice
+ def self.new(parent, name, *args)
+ obj = nil
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
+ obj = SliceID_TBL[parent.path][name]
+ else
+ #super(parent, name, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+ end
+ }
+ obj.instance_eval{
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ }
+
+ obj
+ end
+
+ def initialize(parent, name, *args)
+ # dummy:: not called by 'new' method
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb
new file mode 100644
index 0000000..7d6104f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb
@@ -0,0 +1,22 @@
+#
+# ::vu::spinbox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# a standard spinbox (<= 8.3)
+# This is the same as the 8.4 core spinbox widget.
+#
+require 'tk'
+
+if (Tk::TK_MAJOR_VERSION < 8 ||
+ (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION < 4))
+ # call setup script -- <libdir>/tkextlib/vu.rb
+ require 'tkextlib/vu.rb'
+
+ Tk.tk_call('namespace', 'import', '::vu::spinbox')
+end
+
+module Tk
+ module Vu
+ Spinbox = Tk::Spinbox
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/winico.rb b/jni/ruby/ext/tk/lib/tkextlib/winico.rb
new file mode 100644
index 0000000..ce7b8ea
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/winico.rb
@@ -0,0 +1,14 @@
+#
+# winico -- Windows Icon extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# load library
+require 'tkextlib/winico/winico'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb b/jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb
new file mode 100644
index 0000000..9160c29
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb
@@ -0,0 +1,224 @@
+#
+# tkextlib/winico/winico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/winico/setup.rb'
+
+# TkPackage.require('winico', '0.5')
+# TkPackage.require('winico', '0.6')
+TkPackage.require('winico')
+
+module Tk
+ class Winico < TkObject
+ PACKAGE_NAME = 'winico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('winico')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Winico
+ WinicoID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ WinicoID_TBL.mutex.synchronize{ WinicoID_TBL.clear }
+ }
+
+ def self.id2obj(id)
+ WinicoID_TBL.mutex.synchronize{
+ (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ }
+ end
+
+ def self.info
+ simplelist(Tk.tk_call('winico', 'info')).collect{|id|
+ Tk::Winico.id2obj(id)
+ }
+ end
+
+ def self.icon_info(id)
+ simplelist(Tk.tk_call('winico', 'info', id)).collect{|inf|
+ h = Hash[*list(inf)]
+ h.keys.each{|k| h[k[1..-1]] = h.delete(k)}
+ }
+ end
+
+ #################################
+
+ def self.new_from_file(file_name)
+ self.new(file_name)
+ end
+
+ def self.new_from_resource(resource_name, file_name = nil)
+ self.new(file_name, resource_name)
+ end
+
+ def initialize(file_name, resource_name=nil, winico_id=nil)
+ if resource_name
+ # from resource
+ if file_name
+ @id = Tk.tk_call('winico', 'load', resource_name, file_name)
+ else
+ @id = Tk.tk_call('winico', 'load', resource_name)
+ end
+ elsif file_name
+ # from .ico file
+ @id = Tk.tk_call('winico', 'createfrom', file_name)
+ elsif winico_id
+ @id = winico_id
+ else
+ fail ArgumentError,
+ "must be given proper information from where loading icons"
+ end
+ @path = @id
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL[@id] = self
+ }
+ end
+
+ def id
+ @id
+ end
+
+ def set_window(win_id, *opts) # opts := ?'big'|'small'?, ?pos?
+ # NOTE:: the window, which is denoted by win_id, MUST BE MAPPED.
+ # If not, then this may fail or crash.
+ tk_call('winico', 'setwindow', win_id, @id, *opts)
+ end
+
+ def delete
+ tk_call('winico', 'delete', @id)
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL.delete(@id)
+ }
+ self
+ end
+ alias destroy delete
+
+ def info
+ Tk::Winico.icon_info(@id)
+ end
+
+ #################################
+
+ class Winico_callback < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?m, ?s, :message ],
+ [ ?i, ?x, :icon ],
+ [ ?x, ?n, :x ],
+ [ ?y, ?n, :y ],
+ [ ?X, ?n, :last_x ],
+ [ ?Y, ?n, :last_y ],
+ [ ?t, ?n, :tickcount ],
+ [ ?w, ?n, :icon_idnum ],
+ [ ?l, ?n, :msg_idnum ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?x, proc{|id|
+ Tk::Winico::WinicoID_TBL.mutex.synchronize{
+ if Tk::Winico::WinicoID_TBL.key?(id)
+ obj = Tk::Winico::WinicoID_TBL[id]
+ else
+ # Tk::Winico.new(nil, nil, id)
+ obj = Tk::Winico.allocate
+ obj.instance_eval{ @path = @id = id }
+ Tk::Winico::WinicoID_TBL[id] = obj
+ end
+ obj
+ }
+ } ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['callback']
+ end
+ end
+
+ #################################
+
+ def add_to_taskbar(keys = {})
+ keys = _symbolkey2str(keys)
+ Winico_callback._config_keys.each{|k|
+ if keys[k].kind_of?(Array)
+ cmd, *args = keys[k]
+ #keys[k] = Winico_callback.new(cmd, args.join(' '))
+ keys[k] = Winico_callback.new(cmd, *args)
+ # elsif keys[k].kind_of?(Proc)
+ elsif TkComm._callback_entry?(keys[k])
+ keys[k] = Winico_callback.new(keys[k])
+ end
+ }
+ tk_call('winico', 'taskbar', 'add', @id, *(hash_kv(keys)))
+ self
+ end
+ alias taskbar_add add_to_taskbar
+
+ def modify_taskbar(keys = {})
+ keys = _symbolkey2str(keys)
+ Winico_callback._config_keys.each{|k|
+ if keys[k].kind_of?(Array)
+ cmd, *args = keys[k]
+ #keys[k] = Winico_callback.new(cmd, args.join(' '))
+ keys[k] = Winico_callback.new(cmd, *args)
+ # elsif keys[k].kind_of?(Proc)
+ elsif TkComm._callback_entry?(keys[k])
+ keys[k] = Winico_callback.new(keys[k])
+ end
+ }
+ tk_call('winico', 'taskbar', 'modify', @id, *(hash_kv(keys)))
+ self
+ end
+ alias taskbar_modify modify_taskbar
+
+ def delete_from_taskbar
+ tk_call('winico', 'taskbar', 'delete', @id)
+ self
+ end
+ alias taskbar_delete delete_from_taskbar
+end