From 6175ca03be6d0d51359f9017123708987d0f5eb7 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 15 Aug 2007 23:23:39 +0000 Subject: add tag v1_8_5_91 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_91@13046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby_1_8_5/ext/tk/lib/tkextlib/ICONS.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/icons.rb | 129 ++ ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/SUPPORT_STATUS | 196 ++ ruby_1_8_5/ext/tk/lib/tkextlib/blt.rb | 187 ++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/barchart.rb | 79 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/bitmap.rb | 99 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/busy.rb | 82 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/component.rb | 1835 ++++++++++++++++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/container.rb | 28 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/cutbuffer.rb | 23 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/dragdrop.rb | 214 ++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/eps.rb | 32 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/graph.rb | 67 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/htext.rb | 110 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/spline.rb | 23 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/stripchart.rb | 74 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/table.rb | 344 +++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabnotebook.rb | 21 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabset.rb | 401 ++++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/ted.rb | 62 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile.rb | 21 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/button.rb | 16 + .../ext/tk/lib/tkextlib/blt/tile/checkbutton.rb | 17 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/frame.rb | 16 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/label.rb | 16 + .../ext/tk/lib/tkextlib/blt/tile/radiobutton.rb | 17 + .../ext/tk/lib/tkextlib/blt/tile/scrollbar.rb | 16 + .../ext/tk/lib/tkextlib/blt/tile/toplevel.rb | 16 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/tree.rb | 923 ++++++++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/treeview.rb | 1146 ++++++++++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/unix_dnd.rb | 129 ++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/vector.rb | 243 ++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/watch.rb | 142 ++ ruby_1_8_5/ext/tk/lib/tkextlib/blt/win_printer.rb | 61 + ruby_1_8_5/ext/tk/lib/tkextlib/blt/winop.rb | 107 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget.rb | 151 ++ .../ext/tk/lib/tkextlib/bwidget/arrowbutton.rb | 21 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/bitmap.rb | 21 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/button.rb | 31 + .../ext/tk/lib/tkextlib/bwidget/buttonbox.rb | 78 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/combobox.rb | 45 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dialog.rb | 157 ++ ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dragsite.rb | 31 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dropsite.rb | 39 + .../ext/tk/lib/tkextlib/bwidget/dynamichelp.rb | 56 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/entry.rb | 43 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/label.rb | 41 + .../ext/tk/lib/tkextlib/bwidget/labelentry.rb | 80 + .../ext/tk/lib/tkextlib/bwidget/labelframe.rb | 46 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/listbox.rb | 339 +++ .../ext/tk/lib/tkextlib/bwidget/mainframe.rb | 92 + .../ext/tk/lib/tkextlib/bwidget/messagedlg.rb | 178 ++ ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/notebook.rb | 148 ++ .../ext/tk/lib/tkextlib/bwidget/pagesmanager.rb | 61 + .../ext/tk/lib/tkextlib/bwidget/panedwindow.rb | 31 + .../ext/tk/lib/tkextlib/bwidget/panelframe.rb | 51 + .../ext/tk/lib/tkextlib/bwidget/passwddlg.rb | 44 + .../ext/tk/lib/tkextlib/bwidget/progressbar.rb | 20 + .../ext/tk/lib/tkextlib/bwidget/progressdlg.rb | 54 + .../ext/tk/lib/tkextlib/bwidget/scrollableframe.rb | 34 + .../ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb | 32 + .../ext/tk/lib/tkextlib/bwidget/scrollview.rb | 25 + .../ext/tk/lib/tkextlib/bwidget/selectcolor.rb | 45 + .../ext/tk/lib/tkextlib/bwidget/selectfont.rb | 85 + .../ext/tk/lib/tkextlib/bwidget/separator.rb | 20 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/spinbox.rb | 98 + .../ext/tk/lib/tkextlib/bwidget/statusbar.rb | 46 + .../ext/tk/lib/tkextlib/bwidget/titleframe.rb | 27 + ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/tree.rb | 434 ++++ ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/widget.rb | 113 + ruby_1_8_5/ext/tk/lib/tkextlib/itcl.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/itcl/incr_tcl.rb | 172 ++ ruby_1_8_5/ext/tk/lib/tkextlib/itcl/setup.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/itk.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/itk/incr_tk.rb | 428 ++++ ruby_1_8_5/ext/tk/lib/tkextlib/itk/setup.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets.rb | 94 + .../ext/tk/lib/tkextlib/iwidgets/buttonbox.rb | 119 + .../ext/tk/lib/tkextlib/iwidgets/calendar.rb | 106 + .../ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb | 53 + .../tk/lib/tkextlib/iwidgets/canvasprintdialog.rb | 38 + .../ext/tk/lib/tkextlib/iwidgets/checkbox.rb | 116 + .../ext/tk/lib/tkextlib/iwidgets/combobox.rb | 104 + .../ext/tk/lib/tkextlib/iwidgets/dateentry.rb | 20 + .../ext/tk/lib/tkextlib/iwidgets/datefield.rb | 58 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialog.rb | 20 + .../ext/tk/lib/tkextlib/iwidgets/dialogshell.rb | 119 + .../tk/lib/tkextlib/iwidgets/disjointlistbox.rb | 50 + .../ext/tk/lib/tkextlib/iwidgets/entryfield.rb | 166 ++ .../ext/tk/lib/tkextlib/iwidgets/extbutton.rb | 40 + .../lib/tkextlib/iwidgets/extfileselectionbox.rb | 46 + .../tkextlib/iwidgets/extfileselectiondialog.rb | 33 + .../ext/tk/lib/tkextlib/iwidgets/feedback.rb | 35 + .../tk/lib/tkextlib/iwidgets/fileselectionbox.rb | 46 + .../lib/tkextlib/iwidgets/fileselectiondialog.rb | 33 + .../ext/tk/lib/tkextlib/iwidgets/finddialog.rb | 42 + .../ext/tk/lib/tkextlib/iwidgets/hierarchy.rb | 309 +++ .../ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb | 50 + .../ext/tk/lib/tkextlib/iwidgets/labeledframe.rb | 39 + .../ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb | 45 + .../ext/tk/lib/tkextlib/iwidgets/mainwindow.rb | 67 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/menubar.rb | 210 ++ .../ext/tk/lib/tkextlib/iwidgets/messagebox.rb | 91 + .../ext/tk/lib/tkextlib/iwidgets/messagedialog.rb | 20 + .../ext/tk/lib/tkextlib/iwidgets/notebook.rb | 168 ++ .../ext/tk/lib/tkextlib/iwidgets/optionmenu.rb | 92 + .../ext/tk/lib/tkextlib/iwidgets/panedwindow.rb | 132 ++ .../ext/tk/lib/tkextlib/iwidgets/promptdialog.rb | 131 ++ .../ext/tk/lib/tkextlib/iwidgets/pushbutton.rb | 35 + .../ext/tk/lib/tkextlib/iwidgets/radiobox.rb | 116 + .../ext/tk/lib/tkextlib/iwidgets/scopedobject.rb | 24 + .../ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb | 347 +++ .../ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb | 59 + .../ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb | 58 + .../tk/lib/tkextlib/iwidgets/scrolledlistbox.rb | 207 ++ .../ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb | 538 +++++ .../ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb | 20 + .../ext/tk/lib/tkextlib/iwidgets/selectionbox.rb | 102 + .../tk/lib/tkextlib/iwidgets/selectiondialog.rb | 92 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/shell.rb | 38 + .../ext/tk/lib/tkextlib/iwidgets/spindate.rb | 48 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinint.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinner.rb | 150 ++ .../ext/tk/lib/tkextlib/iwidgets/spintime.rb | 48 + .../ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb | 169 ++ ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabset.rb | 99 + .../ext/tk/lib/tkextlib/iwidgets/timeentry.rb | 25 + .../ext/tk/lib/tkextlib/iwidgets/timefield.rb | 58 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/toolbar.rb | 112 + ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/watch.rb | 56 + ruby_1_8_5/ext/tk/lib/tkextlib/pkg_checker.rb | 184 ++ ruby_1_8_5/ext/tk/lib/tkextlib/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib.rb | 90 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/README | 135 ++ .../ext/tk/lib/tkextlib/tcllib/autoscroll.rb | 158 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ctext.rb | 160 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/cursor.rb | 97 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/datefield.rb | 57 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/dialog.rb | 84 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/getstring.rb | 131 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/history.rb | 73 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ico.rb | 114 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ip_entry.rb | 66 + .../ext/tk/lib/tkextlib/tcllib/panelframe.rb | 72 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/plotchart.rb | 865 ++++++++ ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ruler.rb | 65 + .../ext/tk/lib/tkextlib/tcllib/screenruler.rb | 68 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/scrollwin.rb | 61 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/style.rb | 61 + .../ext/tk/lib/tkextlib/tcllib/superframe.rb | 51 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/swaplist.rb | 147 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist.rb | 27 + .../ext/tk/lib/tkextlib/tcllib/tablelist_core.rb | 770 +++++++ .../ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb | 25 + .../ext/tk/lib/tkextlib/tcllib/tkpiechart.rb | 308 +++ ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tooltip.rb | 95 + ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/widget.rb | 48 + ruby_1_8_5/ext/tk/lib/tkextlib/tclx.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/tclx/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tclx/tclx.rb | 74 + ruby_1_8_5/ext/tk/lib/tkextlib/tile.rb | 225 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tile/dialog.rb | 84 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/style.rb | 103 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tbutton.rb | 30 + .../ext/tk/lib/tkextlib/tile/tcheckbutton.rb | 32 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcombobox.rb | 55 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tentry.rb | 40 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tframe.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabel.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabelframe.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tmenubutton.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tnotebook.rb | 110 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tpaned.rb | 188 ++ .../ext/tk/lib/tkextlib/tile/tprogressbar.rb | 53 + .../ext/tk/lib/tkextlib/tile/tradiobutton.rb | 32 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/treeview.rb | 280 +++ ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscale.rb | 50 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscrollbar.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tseparator.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tile/tsquare.rb | 30 + ruby_1_8_5/ext/tk/lib/tkextlib/tkDND.rb | 18 + ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/shape.rb | 123 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/tkdnd.rb | 164 ++ ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML.rb | 13 + .../ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb | 444 ++++ ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg.rb | 36 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/README | 26 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/bmp.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/gif.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ico.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/jpeg.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pcx.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pixmap.rb | 44 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/png.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ppm.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ps.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/sgi.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/sun.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/tga.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/tiff.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/window.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/xbm.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/xpm.rb | 33 + ruby_1_8_5/ext/tk/lib/tkextlib/tktable.rb | 14 + ruby_1_8_5/ext/tk/lib/tkextlib/tktable/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tktable/tktable.rb | 839 +++++++ ruby_1_8_5/ext/tk/lib/tkextlib/tktrans.rb | 14 + ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/tktrans.rb | 64 + ruby_1_8_5/ext/tk/lib/tkextlib/treectrl.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/setup.rb | 8 + .../ext/tk/lib/tkextlib/treectrl/tktreectrl.rb | 2311 ++++++++++++++++++++ ruby_1_8_5/ext/tk/lib/tkextlib/trofs.rb | 13 + ruby_1_8_5/ext/tk/lib/tkextlib/trofs/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/trofs/trofs.rb | 51 + ruby_1_8_5/ext/tk/lib/tkextlib/vu.rb | 48 + ruby_1_8_5/ext/tk/lib/tkextlib/vu/bargraph.rb | 61 + ruby_1_8_5/ext/tk/lib/tkextlib/vu/charts.rb | 53 + ruby_1_8_5/ext/tk/lib/tkextlib/vu/dial.rb | 102 + ruby_1_8_5/ext/tk/lib/tkextlib/vu/pie.rb | 235 ++ ruby_1_8_5/ext/tk/lib/tkextlib/vu/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/vu/spinbox.rb | 22 + ruby_1_8_5/ext/tk/lib/tkextlib/winico.rb | 14 + ruby_1_8_5/ext/tk/lib/tkextlib/winico/setup.rb | 8 + ruby_1_8_5/ext/tk/lib/tkextlib/winico/winico.rb | 189 ++ 234 files changed, 26630 insertions(+) create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/ICONS.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/icons.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/SUPPORT_STATUS create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/barchart.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/bitmap.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/busy.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/component.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/container.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/cutbuffer.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/dragdrop.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/eps.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/graph.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/htext.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/spline.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/stripchart.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/table.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabnotebook.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabset.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/ted.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/button.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/frame.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/label.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/toplevel.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/tree.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/treeview.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/unix_dnd.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/vector.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/watch.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/win_printer.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/blt/winop.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/bitmap.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/button.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/buttonbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/combobox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dragsite.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dropsite.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/entry.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/label.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelentry.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/listbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/mainframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/messagedlg.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/notebook.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panedwindow.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panelframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/passwddlg.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressbar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressdlg.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollview.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectcolor.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectfont.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/separator.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/spinbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/statusbar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/titleframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/tree.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/widget.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/itcl.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/itcl/incr_tcl.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/itcl/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/itk.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/itk/incr_tk.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/itk/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/calendar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/checkbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/combobox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dateentry.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/datefield.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/entryfield.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extbutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/feedback.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/finddialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/menubar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagebox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/notebook.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/radiobox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/shell.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spindate.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinint.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinner.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spintime.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabset.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/timeentry.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/timefield.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/toolbar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/watch.rb create mode 100755 ruby_1_8_5/ext/tk/lib/tkextlib/pkg_checker.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/README create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/autoscroll.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ctext.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/cursor.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/datefield.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/dialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/getstring.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/history.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ico.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ip_entry.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/panelframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/plotchart.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ruler.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/screenruler.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/scrollwin.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/style.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/superframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/swaplist.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tooltip.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/widget.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tclx.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tclx/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tclx/tclx.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/dialog.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/style.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tbutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcheckbutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcombobox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tentry.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabel.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabelframe.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tmenubutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tnotebook.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tpaned.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tprogressbar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tradiobutton.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/treeview.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscale.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscrollbar.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tseparator.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tile/tsquare.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkDND.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/shape.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/tkdnd.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/README create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/bmp.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/gif.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ico.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/jpeg.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pcx.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pixmap.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/png.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ppm.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ps.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/sgi.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/sun.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/tga.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/tiff.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/window.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/xbm.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/xpm.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tktable.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tktable/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tktable/tktable.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tktrans.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/tktrans.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/treectrl.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/trofs.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/trofs/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/trofs/trofs.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu/bargraph.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu/charts.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu/dial.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu/pie.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/vu/spinbox.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/winico.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/winico/setup.rb create mode 100644 ruby_1_8_5/ext/tk/lib/tkextlib/winico/winico.rb (limited to 'ruby_1_8_5/ext/tk/lib/tkextlib') diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/ICONS.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/ICONS.rb new file mode 100644 index 0000000000..18d84c05e9 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/icons.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/icons.rb new file mode 100644 index 0000000000..b430bae55d --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/ICONS/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ruby_1_8_5/ext/tk/lib/tkextlib/SUPPORT_STATUS new file mode 100644 index 0000000000..8d7b6fc44a --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/SUPPORT_STATUS @@ -0,0 +1,196 @@ + + [ current support status of Tcl/Tk extensions ] + + *******<<< RELEASE_DATE of the libraries : 2005/12/11 >>>******* + +The following list shows *CURRENT* status when this file was modifyed +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 extention work? + + (2) Do DLL libraries of the extension exist on DLL load-path? + (See also "/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 oprations into the "setup.rb" file in the directory + of the wrapper libraries for the extention (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()). + + ******************************************************************* + + +===< support with some examples (may be beta quality) >======================= + +Tcllib 1.8 +Tklib 0.4.1 http://sf.net/projects/tcllib ==> tcllib + +IWidgets 4.0.2 http://sf.net/projects/incrTcl ==> iwidgets + +BWidgets 1.7 http://sf.net/projects/tcllib ==> bwidget + +TkTable 2.9 http://sf.net/projects/tktable ==> tktable + * see also + written by Ferenc Engard (ferenc@engard.hu) + +vu 2.3.0 http://tktable.sourceforge.net ==> vu + +TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML + +ICONS 1.0 http://www.satisoft.com/tcltk/icons/ ==> ICONS + +TkImg 1.3 http://sf.net/projects/tkimg ==> tkimg + + +BLT 2.4z http://sourceforge.net/projects/blt + * see also tcltk-ext library on RAA + (http://raa.ruby-lang.org/) + ==> blt + +TkTreeCtrl CVS/Hd(2005-12-02) + http://tktreectrl.sourceforge.net/ ==> treectrl + +Tile CVS/Hd(2005-12-07) + http://tktable.sourceforge.net/tile/ ==> tile + + + +===< support (may be alpha or beta quality) >================================= + +IncrTcl CVS/Hd(2005-02-14) + http://sf.net/projects/incrTcl ==> itcl, itk + +TclX CVS/Hd(2005-02-07) + http://sf.net/projects/tclx + ==> tclx (partial support; infox command and + XPG/3 message catalogs only) + +Trofs 0.4.3 http://math.nist.gov/~DPorter/tcltk/trofs/ + + + +===< possibly available (not tested; alpha quality) >========================= + +winico 0.6 + http://tktable.sourceforge.net + ==> 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/ + * see also tcltk-ext library on RAA + (http://raa.ruby-lang.org/) + +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://sf.net/projects/tkcon + +Expect *** http://sf.net/projects/expect + +TclXML *** http://sf.net/projects/tclxml + +TclXSLT *** http://sf.net/projects/tclxml + +TclDOM *** http://sf.net/projects/tclxml + +TclSOAP *** http://sf.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://memchan.sourceforge.net/ + +XOTcl *** http://www.xotcl.org/ + + +===< tool (may not supprt) >================================================== + +tbcload/tclcompiler + *** http://www.tcl.tk/software/tclpro/ + + +(End of List) diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt.rb new file mode 100644 index 0000000000..8ac8605513 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt.rb @@ -0,0 +1,187 @@ +# +# 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) + + extend TkCore + + VERSION = tk_call('set', 'blt_version') + PATCH_LEVEL = tk_call('set', 'blt_patchLevel') + + begin + lib = INTERP._invoke('set', 'blt_library') + rescue + lib = '' + end + LIBRARY = TkVarAccess.new('blt_library', lib) + + begin + lib = 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 << '--' + 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 << '--' + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/barchart.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/barchart.rb new file mode 100644 index 0000000000..cb481c5889 --- /dev/null +++ b/ruby_1_8_5/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, '00000'.taint].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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/bitmap.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/bitmap.rb new file mode 100644 index 0000000000..31cf8d4229 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/bitmap.rb @@ -0,0 +1,99 @@ +# +# 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, '00000'.taint].freeze + + 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 + @id = BITMAP_ID.join(TkCore::INTERP._ip_id_) + BITMAP_ID[1].succ! + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/busy.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/busy.rb new file mode 100644 index 0000000000..4726e466f4 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/busy.rb @@ -0,0 +1,82 @@ +# +# 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?(TkToplevel) + 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 + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/component.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/component.rb new file mode 100644 index 0000000000..ad78a5430b --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/component.rb @@ -0,0 +1,1835 @@ +# +# 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(id, option) + ret = itemcget(['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(option) + itemcget('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(id, option) + itemcget(['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(id, option) + itemcget(['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(id, option) + itemcget(['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(option) + itemcget('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(option) + itemcget('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(id, option) + itemcget(['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(option) + itemcget('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(id, option) + itemcget(['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 itemcget + alias __itemconfiginfo itemconfiginfo + alias __current_itemconfiginfo current_itemconfiginfo + private :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo + + def itemcget(tagOrId, option) + ret = __itemcget(tagid(tagOrId), option) + if option == 'bindtags' || option == :bindtags + ret.collect{|tag| TkBindTag.id2obj(tag)} + else + ret + 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, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + + ################# + + class Axis < TkObject + OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint].freeze + OBJ_TBL={} + + def self.id2obj(chart, id) + cpath = chart.path + return id unless OBJ_TBL[cpath] + OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id + end + + def self.new(chart, axis=nil, keys={}) + if axis.kind_of?(Hash) + keys = axis + axis = nil + end + OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path] + return OBJ_TBL[chart.path][axis] if axis && OBJ_TBL[chart.path][axis] + super(chart, axis, keys) + end + + def initialize(chart, axis=nil, keys={}) + if axis.kind_of?(Hash) + keys = axis + axis = nil + end + if axis + @axis = @id = axis.to_s + else + @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze + OBJ_ID[1].succ! + end + @path = @id + @parent = @chart = chart + @cpath = @chart.path + Axis::OBJ_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(option) + @chart.axis_cget(@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 + OBJ_TBL={} + + def self.new(chart, keys={}) + return OBJ_TBL[chart.path] if OBJ_TBL[chart.path] + super(chart, keys) + end + + def initialize(chart, keys={}) + @parent = @chart = chart + @cpath = @chart.path + Crosshairs::OBJ_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(option) + @chart.crosshair_cget(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.clear } + + OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint].freeze + OBJ_TBL={} + + def Element.type2class(type) + ElementTypeToClass[type] + end + + def Element.id2obj(chart, id) + cpath = chart.path + return id unless OBJ_TBL[cpath] + OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id + end + + def self.new(chart, element=nil, keys={}) + if element.kind_of?(Hash) + keys = element + element = nil + end + OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path] + if element && OBJ_TBL[chart.path][element] + return OBJ_TBL[chart.path][element] + end + super(chart, element, keys) + end + + def initialize(chart, element=nil, keys={}) + if element.kind_of?(Hash) + keys = element + element = nil + end + if element + @element = @id = element.to_s + else + @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::OBJ_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(option) + # @chart.element_cget(@id, option) + @chart.__send__(@typename + '_cget', @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 + OBJ_TBL={} + + def self.new(chart, keys={}) + return OBJ_TBL[chart.path] if OBJ_TBL[chart.path] + super(chart, keys) + end + + def initialize(chart, keys={}) + @parent = @chart = chart + @cpath = @chart.path + GridLine::OBJ_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(option) + @chart.gridline_cget(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 + OBJ_TBL={} + + def self.new(chart, keys={}) + return OBJ_TBL[chart.path] if OBJ_TBL[chart.path] + super(chart, keys) + end + + def initialize(chart, keys={}) + @parent = @chart = chart + @cpath = @chart.path + Crosshairs::OBJ_TBL[@cpath] = self + @chart.crosshair_configure(keys) unless keys.empty? + @path = @id = 'legend' + end + + def id + @id + end + + def to_eval + @id + end + + def cget(option) + @chart.legend_cget(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, '00000'.taint].freeze + OBJ_TBL={} + + def self.id2obj(chart, id) + cpath = chart.path + return id unless OBJ_TBL[cpath] + OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id + end + + def self.new(chart, pen=nil, keys={}) + if pen.kind_of?(Hash) + keys = pen + pen = nil + end + OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path] + return OBJ_TBL[chart.path][pen] if pen && OBJ_TBL[chart.path][pen] + super(chart, pen, keys) + 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 + @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze + OBJ_ID[1].succ! + end + @path = @id + @parent = @chart = chart + @cpath = @chart.path + Pen::OBJ_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(option) + @chart.pen_cget(@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 + OBJ_TBL={} + + def self.new(chart, keys={}) + return OBJ_TBL[chart.path] if OBJ_TBL[chart.path] + super(chart, keys) + end + + def initialize(chart, keys={}) + @parent = @chart = chart + @cpath = @chart.path + Postscript::OBJ_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(option) + @chart.postscript_cget(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.clear } + + def Marker.type2class(type) + MarkerTypeToClass[type] + end + + def Marker.id2obj(chart, id) + cpath = chart.path + return id unless MarkerID_TBL[cpath] + MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id + 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_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] + 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 = _parse_create_args(keys) + idnum = tk_call_without_enc(chart.path, 'marker', 'create', + self::MarkerTypeName, *args) + chart.marker_configure(idnum, fontkeys) unless fontkeys.empty? + idnum.to_i # 'item id' is an integer number + end + + def self.create_type(chart, type, keys={}) + args, fontkeys = _parse_create_args(keys) + idnum = tk_call_without_enc(chart.path, 'marker', 'create', + type, *args) + chart.marker_configure(idnum, fontkeys) unless fontkeys.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 + unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] + Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {} + end + 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' + unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] + Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {} + end + 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(option) + @chart.marker_cget(@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::OBJ_TBL.delete(@path) + Crosshairs::OBJ_TBL.delete(@path) + Element::OBJ_TBL.delete(@path) + GridLine::OBJ_TBL.delete(@path) + Legend::OBJ_TBL.delete(@path) + Pen::OBJ_TBL.delete(@path) + Postscript::OBJ_TBL.delete(@path) + Marker::OBJ_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 paramters + 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(option) + itemcget('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(option) + itemcget('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(option) + itemcget('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(option) + itemcget('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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/container.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/container.rb new file mode 100644 index 0000000000..60ba1dec1e --- /dev/null +++ b/ruby_1_8_5/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 + end + + def __strval_optkeys + super() << 'name' + end + private :__strval_optkeys + + def find_command(pat) + list(tk_send_without_enc(tk_call(self.path, 'find', '-command', pat))) + end + + def find_name(pat) + list(tk_send_without_enc(tk_call(self.path, 'find', '-name', pat))) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/cutbuffer.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/cutbuffer.rb new file mode 100644 index 0000000000..1cc39dfb94 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/dragdrop.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/dragdrop.rb new file mode 100644 index 0000000000..68fb9e591a --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/dragdrop.rb @@ -0,0 +1,214 @@ +# +# 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 + 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 + ] + + _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 + ] + + _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 + ] + + _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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/eps.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/eps.rb new file mode 100644 index 0000000000..586a42470c --- /dev/null +++ b/ruby_1_8_5/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 TkCanvas + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/graph.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/graph.rb new file mode 100644 index 0000000000..9ae99bff5c --- /dev/null +++ b/ruby_1_8_5/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, '00000'.taint].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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/htext.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/htext.rb new file mode 100644 index 0000000000..a0cf3dc036 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/htext.rb @@ -0,0 +1,110 @@ +# +# 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 Htexttrue) + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/table.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/table.rb new file mode 100644 index 0000000000..fc1bf54e65 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/table.rb @@ -0,0 +1,344 @@ +# +# 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(@path, *args) + self + end + + def blt_table_arrange() + Tk::BLT::Table.arrange(@path) + self + end + + def blt_table_cget(*args) + Tk::BLT::Table.cget(@path, *args) + end + + def blt_table_configure(*args) + Tk::BLT::Table.configure(@path, *args) + self + end + + def blt_table_configinfo(*args) + Tk::BLT::Table.configinfo(@path, *args) + end + + def blt_table_current_configinfo(*args) + Tk::BLT::Table.current_configinfo(@path, *args) + end + + def blt_table_locate(x, y) + Tk::BLT::Table.locate(@path, x, y) + end + + def blt_table_delete(*args) + Tk::BLT::Table.delete(@path, *args) + self + end + + def blt_table_extents(item) + Tk::BLT::Table.extents(@path, item) + end + + def blt_table_insert(*args) + Tk::BLT::Table.insert(@path, *args) + self + end + + def blt_table_insert_before(*args) + Tk::BLT::Table.insert_before(@path, *args) + self + end + + def blt_table_insert_after(*args) + Tk::BLT::Table.insert_after(@path, *args) + self + end + + def blt_table_join(first, last) + Tk::BLT::Table.join(@path, first, last) + self + end + + def blt_table_save() + Tk::BLT::Table.save(@path) + end + + def blt_table_search(*args) + Tk::BLT::Table.search(@path, *args) + end + + def blt_table_split(*args) + Tk::BLT::Table.split(@path, *args) + self + end + + def blt_table_itemcget(*args) + Tk::BLT::Table.itemcget(@path, *args) + end + + def blt_table_itemconfigure(*args) + Tk::BLT::Table.itemconfigure(@path, *args) + self + end + + def blt_table_itemconfiginfo(*args) + Tk::BLT::Table.itemconfiginfo(@path, *args) + end + + def blt_table_current_itemconfiginfo(*args) + Tk::BLT::Table.current_itemconfiginfo(@path, *args) + end + + def blt_table_iteminfo(item) + Tk::BLT::Table.iteminfo(@path, item) + end + end + end +end + + +############################################ +class << Tk::BLT::Table + def __item_cget_cmd(id) # id := [ container, item ] + ['::blt::table', 'cget', id[0].path, id[1]] + end + private :__item_cget_cmd + + def __item_config_cmd(id) # id := [ container, item, ... ] + container, *items = id + ['::blt::table', 'configure', container.path, *items] + end + private :__item_config_cmd + + def __item_pathname(id) + id[0].path + ';' + end + private :__item_pathname + + alias __itemcget itemcget + alias __itemconfigure itemconfigure + alias __itemconfiginfo itemconfiginfo + alias __current_itemconfiginfo current_itemconfiginfo + + private :__itemcget, :__itemconfigure + private :__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(container, option) + __itemcget([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(container, item, option) + __itemcget([container, tagid(item)], option) + end + + def itemconfigure(container, *args) + if args[-1].kind_of?(Hash) + # container, item, item, ... , hash_optkeys + keys = args.pop + id = [container] + args.each{|item| id << tagid(item)} + __itemconfigure(id, keys) + else + # container, item, item, ... , option, value + val = args.pop + opt = args.pop + id = [container] + args.each{|item| id << tagid(item)} + __itemconfigure(id, opt, val) + end + 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 + + id = [container] + args.each{|item| id << tagid(item)} + __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) + ret = {} + inf = list(tk_call('::blt::table', 'info', container, tagid(item))) + until inf.empty? + opt = inf.slice!(0..1) + ret[opt[1..-1]] = opt[1] + 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 + end + + def arrange(container) + tk_call('::blt::table', 'arrange', 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabnotebook.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabnotebook.rb new file mode 100644 index 0000000000..508fa2b82f --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabnotebook.rb @@ -0,0 +1,21 @@ +# +# 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 + + def get_tab(index) + Tk::BLT::Tabset::Tab.id2obj(tk_send_without_enc('id', tagindex(index))) + end + alias get_id get_tab + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabset.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabset.rb new file mode 100644 index 0000000000..c26b6ee001 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tabset.rb @@ -0,0 +1,401 @@ +# +# 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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ TabID_TBL.clear } + + def self.id2obj(tabset, id) + tpath = tabset.path + return id unless TabID_TBL[tpath] + TabID_TBL[tpath][id]? TabID_TBL[tpath]: id + 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 + + if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name] + TabID_TBL[parent.path][name] + else + super(parent, pos, name, keys) + end + end + + def initialize(parent, pos, name, keys) + @t = parent + @tpath = parent.path + if name + @path = @id = name + TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath] + TabID_TBL[@tpath][@id] = self + + 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, idx, 'moveto', 'after', 'end') + else + tk_call(@tpath, idx, 'moveto', 'before', pos) + end + end + tk_call(@tpath, 'tab', 'configure', @id, keys) + return + end + + else + @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_) + TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath] + TabID_TBL[@tpath][@id] = self + TabsetTab_ID[1].succ! + end + + pos = 'end' unless pos + tk_call(@tpath, 'insert', pos, @id, keys) + 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(*args) + @t.tab_cget(@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[@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.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 itemcget + 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[@path].delete(first.id) + end + # middle tabs of the range are unknown + if last.kind_of?(Tk::BLT::Tabset::Tab) + TabID_TBL[@path].delete(last.id) + end + self + end + + def focus(index) + tk_send('focus', tagindex(index)) + self + end + + def get_tab(index) + Tk::BLT::Tabset::Tab.id2obj(tk_send_without_enc('get', tagindex(index))) + end + + def index(str) + num_or_str(tk_send('index', str)) + end + def index_name(tab) + num_or_str(tk_send('index', '-mame', tagid(tab))) + end + + def insert(pos, tab, keys={}) + Tk::BLT::Tabset::Tab.new(self, tagindex(pos), tagid(tab), keys) + 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(num_or_str(tk_send_without_enc('nearest', x, y))) + end + + def perforation_highlight(index, mode) + tk_send('perforation', 'highlight', tagindex(index), mode) + self + end + def perforation_invoke(index) + tk_send('perforation', 'invoke', tagindex(index)) + 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_names(pat=None) + simplelist(tk_send('tab', 'names', pat)).collect{|name| + Tk::BLT::Tabset::Tab.id2obj(name) + } + end + + def tab_tearoff(index, name=None) + window(tk_send('tab', 'tearoff', tagindex(index), name)) + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/ted.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/ted.rb new file mode 100644 index 0000000000..39495842b4 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/ted.rb @@ -0,0 +1,62 @@ +# +# 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, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + + def cget(master, option) + itemconfigure(master, slot, value) + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile.rb new file mode 100644 index 0000000000..5f5242f299 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile.rb @@ -0,0 +1,21 @@ +# +# tkextlib/blt/tile.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/blt.rb' + +module Tk::BLT + module Tile + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/button.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/button.rb new file mode 100644 index 0000000000..dd715c8b98 --- /dev/null +++ b/ruby_1_8_5/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 < TkButton + TkCommandNames = ['::blt::tile::button'.freeze].freeze + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb new file mode 100644 index 0000000000..ebe79179a5 --- /dev/null +++ b/ruby_1_8_5/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 < TkCheckbutton + TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze + end + CheckButton = Checkbutton + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/frame.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/frame.rb new file mode 100644 index 0000000000..10469fd35f --- /dev/null +++ b/ruby_1_8_5/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 < TkFrame + TkCommandNames = ['::blt::tile::frame'.freeze].freeze + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/label.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/label.rb new file mode 100644 index 0000000000..ec67babd58 --- /dev/null +++ b/ruby_1_8_5/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 < TkLabel + TkCommandNames = ['::blt::tile::label'.freeze].freeze + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb new file mode 100644 index 0000000000..7573aa08d6 --- /dev/null +++ b/ruby_1_8_5/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 < TkRadiobutton + TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze + end + RadioButton = Radiobutton + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb new file mode 100644 index 0000000000..ba3bf316f0 --- /dev/null +++ b/ruby_1_8_5/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 < TkScrollbar + TkCommandNames = ['::blt::tile::scrollbar'.freeze].freeze + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/toplevel.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tile/toplevel.rb new file mode 100644 index 0000000000..6cc2c91415 --- /dev/null +++ b/ruby_1_8_5/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 < TkToplevel + TkCommandNames = ['::blt::tile::toplevel'.freeze].freeze + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tree.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tree.rb new file mode 100644 index 0000000000..07dc7ef7e8 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/tree.rb @@ -0,0 +1,923 @@ +# +# 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.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless TreeNodeID_TBL[tpath] + if TreeNodeID_TBL[tpath][id] + TreeNodeID_TBL[tpath][id] + else + begin + self.new(tree, nil, 'node'=>Integer(id)) + rescue + id + end + end + end + + def self.new(tree, parent, keys={}) + keys = _symbolkey2str(keys) + tpath = tree.path + + 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 + + super(tree, parent, keys) + end + + def initialize(tree, parent, keys={}) + @parent = @tree = tree + @tpath = @parent.path + + parent = tk_call(@tpath, 'root') unless parent + + 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 + @path = @id = tk_call(@tpath, 'insert', parent, keys) + end + + TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath] + TreeNodeID_TBL[@tpath][@id] = self + 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.clear } + TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint].freeze + + def self.id2obj(tree, id) + tpath = tree.path + return id unless TreeTagID_TBL[tpath] + if TreeTagID_TBL[tpath][id] + TreeTagID_TBL[tpath][id] + else + self.new(tree, 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 + @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_) + TreeTagID_TBL[@id] = self + TreeTag_ID[1].succ! + end + 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[@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.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless NotifyID_TBL[tpath] + if NotifyID_TBL[tpath][id] + NotifyID_TBL[tpath][id] + else + begin + self.new([tree, id]) + rescue + id + end + end + end + + def self.new(tree, *args, &b) + if tree.kind_of?(Array) + # not create + if obj = NotifyID_TBL[tree[0].path][tree[1]] + return obj + else + return super(false, tree[0], tree[1]) + end + end + + super(true, tree, *args, &b) + end + + def initialize(create, tree, *args, &b) + @parent = @tree = tree + @tpath = @parent.path + + unless create + @path = @id = args[0] + return + end + + # 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[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.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless TraceID_TBL[tpath] + if TraceID_TBL[tpath][id] + TraceID_TBL[tpath][id] + else + begin + self.new([tree, id]) + rescue + id + end + end + end + + def self.new(tree, *args, &b) + if tree.kind_of?(Array) + # not create + if obj = TraceID_TBL[tree[0].path][tree[1]] + return obj + else + return super(false, tree[0], tree[1]) + end + end + + super(true, tree, *args, &b) + end + + def initialize(create, tree, node, key, opts, cmd=nil, &b) + @parent = @tree = tree + @tpath = @parent.path + + unless create + @path = @id = node # == traceID + return + end + + 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[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, '00000'.taint].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[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) + return TreeID_TBL[name] if name && TreeID_TBL[name] + super(name) + end + + def initialzie(name = nil) + if name + @path = @id = name + else + @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_) + TreeID_TBL[@id] = self + Tree_ID[1].succ! + end + TreeID_TBL[@id] = self + tk_call('::blt::tree', 'create', @id) + end + + def __destroy_hook__ + Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path) + Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path) + Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path) + 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 paramters + 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)})) + 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[@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[@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) + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/treeview.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/treeview.rb new file mode 100644 index 0000000000..0343d28b9c --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/treeview.rb @@ -0,0 +1,1146 @@ +# +# 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(name, option) + itemcget(['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(option) + itemcget('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(option) + ret = itemcget('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(option) + itemcget('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(option) + itemcget('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, :itemconfigure + private :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 + ] + + _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.delete(@path) + 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 paramters + 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 + ] + + _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(' ')) + 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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless TreeNodeID_TBL[tpath] + if TreeNodeID_TBL[tpath][id] + TreeNodeID_TBL[tpath][id] + else + begin + self.new(tree, nil, nil, 'node'=>Integer(id)) + rescue + id + end + 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 + + 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) + end + + def initialize(tree, pos, parent, keys) + @parent = @tree = tree + @tpath = @parent.path + + if (id = keys['node']) + @path = @id = id + tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent + else + 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 + + TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath] + TreeNodeID_TBL[@tpath][@id] = self + 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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless TreeTagID_TBL[tpath] + if TreeTagID_TBL[tpath][id] + TreeTagID_TBL[tpath][id] + else + begin + self.new(tree, nil, nil, 'name'=>Integer(id)) + rescue + id + end + end + end + + def self.new_by_name(tree, name, *ids) + if (obj = TreeTagID_TBL[tree.path][name]) + return obj + end + new([tree, name], ids) + end + + def self.new(tree, *ids) + if tree.kind_of?(Array) + super(tree[0], tree[1], ids) + else + super(tree, nil, ids) + end + end + + def initialize(tree, name, ids) + @parent = @tree = tree + @tpath = @parent.path + + if name + @path = @id = name + else + @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze + TreeTag_ID[1].succ! + end + + TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath] + TreeTagID_TBL[@tpath][@id] = self + + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/unix_dnd.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/unix_dnd.rb new file mode 100644 index 0000000000..3130c1e56f --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/unix_dnd.rb @@ -0,0 +1,129 @@ +# +# 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, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + + def cget(win, option) + itemconfigure(['cget', win], slot, value) + 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 tokwn_cget(win, option) + itemconfigure(['token', 'cget', win], slot, value) + 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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/vector.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/vector.rb new file mode 100644 index 0000000000..540b6b9102 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/vector.rb @@ -0,0 +1,243 @@ +# +# 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) + simplelist(tk_call('::blt::vector', 'names', pat)).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 = INTERP._invoke('::blt::vector', 'create', + "#auto(#{size})", *hash_kv(keys)) + else + @id = INTERP._invoke('::blt::vector', 'create', + "#auto", *hash_kv(keys)) + end + + 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 + INTERP._invoke_without_enc('global', @id) + end + + def destroy + tk_call('::blt::vector', 'destroy', @id) + end + + def inspect + '#' + 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) + return TkVar_ID_TBL[name] if TkVar_ID_TBL[name] + super(name, size=nil, keys={}) + end + + def initialize(vec_name) + @id = vec_name + 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 + INTERP._invoke_without_enc('global', @id) + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/watch.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/watch.rb new file mode 100644 index 0000000000..ae5e50f126 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/watch.rb @@ -0,0 +1,142 @@ +# +# 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, '00000'.taint].freeze + + def self.names(state = None) + tk_split_list(tk_call('::blt::watch', 'names', state)).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 + @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_) + BLT_WATCH_ID[1].succ! + end + + @path = @id + + 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(key) + key = key.to_s + begin + info.assoc(key)[1] + rescue + fail ArgumentError, "unknown option '#{key}'" + end + end + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/blt/win_printer.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/win_printer.rb new file mode 100644 index 0000000000..7ac6a0dcfc --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/blt/winop.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/blt/winop.rb new file mode 100644 index 0000000000..e371d28ab7 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget.rb new file mode 100644 index 0000000000..62631d8b54 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget.rb @@ -0,0 +1,151 @@ +# +# 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) + + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb new file mode 100644 index 0000000000..770e5e9ef1 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/bitmap.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/bitmap.rb new file mode 100644 index 0000000000..6cfde203e8 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/button.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/button.rb new file mode 100644 index 0000000000..4a9d4a7948 --- /dev/null +++ b/ruby_1_8_5/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 < TkButton + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/buttonbox.rb new file mode 100644 index 0000000000..ef999239f9 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/buttonbox.rb @@ -0,0 +1,78 @@ +# +# 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?(TkButton) + 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))) + win.instance_eval(&b) if b + 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?(TkButton) + 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))) + win.instance_eval(&b) if b + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/combobox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/combobox.rb new file mode 100644 index 0000000000..31f71c3aaf --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/combobox.rb @@ -0,0 +1,45 @@ +# +# 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 get_listbox(&b) + win = window(tk_send_without_enc('getlistbox')) + win.instance_eval(&b) if b + win + end + + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dialog.rb new file mode 100644 index 0000000000..2790d88d24 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dialog.rb @@ -0,0 +1,157 @@ +# +# 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 __strval_optkeys + super() << 'title' + 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(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?(TkButton) + 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))) + win.instance_eval(&b) if b + win + end + + def get_frame(&b) + win = window(tk_send('getframe')) + win.instance_eval(&b) if b + win + end + + def get_buttonbox(&b) + win = window(@path + '.bbox') + win.instance_eval(&b) if b + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dragsite.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dragsite.rb new file mode 100644 index 0000000000..4d4de1780c --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dropsite.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dropsite.rb new file mode 100644 index 0000000000..e5e98fbc51 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb new file mode 100644 index 0000000000..224304f2ab --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb @@ -0,0 +1,56 @@ +# +# 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(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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/entry.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/entry.rb new file mode 100644 index 0000000000..aafb4aa7ff --- /dev/null +++ b/ruby_1_8_5/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 < TkEntry + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/label.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/label.rb new file mode 100644 index 0000000000..ce10ecaf8b --- /dev/null +++ b/ruby_1_8_5/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 < TkLabel + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelentry.rb new file mode 100644 index 0000000000..931feb9b48 --- /dev/null +++ b/ruby_1_8_5/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 < TkEntry + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelframe.rb new file mode 100644 index 0000000000..f7b267eebb --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/labelframe.rb @@ -0,0 +1,46 @@ +# +# 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')) + win.instance_eval(&b) if b + win + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/listbox.rb new file mode 100644 index 0000000000..1267500661 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/listbox.rb @@ -0,0 +1,339 @@ +# +# 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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ ListItem_TBL.clear } + + def self.id2obj(lbox, id) + lpath = lbox.path + return id unless ListItem_TBL[lpath] + ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id + 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 + @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_) + ListItem_ID[1].succ! + end + + 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(key) + @listbox.itemcget(@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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/mainframe.rb new file mode 100644 index 0000000000..c54e878557 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/mainframe.rb @@ -0,0 +1,92 @@ +# +# 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))) + win.instance_eval(&b) if b + win + end + + def add_toolbar(&b) + win = window(tk_send('addtoolbar')) + win.instance_eval(&b) if b + win + end + + def get_frame(&b) + win = window(tk_send('getframe')) + win.instance_eval(&b) if b + win + end + + def get_indicator(idx, &b) + win = window(tk_send('getindicator', idx)) + win.instance_eval(&b) if b + win + end + + def get_menu(menu_id, &b) + win = window(tk_send('getmenu', menu_id)) + win.instance_eval(&b) if b + win + end + + def get_toolbar(idx, &b) + win = window(tk_send('gettoolbar', idx)) + win.instance_eval(&b) if b + win + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/messagedlg.rb new file mode 100644 index 0000000000..9c946d0630 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/messagedlg.rb @@ -0,0 +1,178 @@ +# +# 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 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 + num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/notebook.rb new file mode 100644 index 0000000000..5146d4915d --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/notebook.rb @@ -0,0 +1,148 @@ +# +# 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))) + win.instance_eval(&b) if b + 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))) + win.instance_eval(&b) if b + 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))) + win.instance_eval(&b) if b + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb new file mode 100644 index 0000000000..fc01284be6 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb @@ -0,0 +1,61 @@ +# +# 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))) + win.instance_eval(&b) if b + 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))) + win.instance_eval(&b) if b + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panedwindow.rb new file mode 100644 index 0000000000..19982c6095 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panedwindow.rb @@ -0,0 +1,31 @@ +# +# 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 add(keys={}) + window(tk_send('add', *hash_kv(keys))) + end + + def get_frame(idx, &b) + win = window(tk_send_without_enc('getframe', idx)) + win.instance_eval(&b) if b + win + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panelframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panelframe.rb new file mode 100644 index 0000000000..13f8817d74 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/panelframe.rb @@ -0,0 +1,51 @@ +# +# 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')) + win.instance_eval(&b) if b + win + end + + def items + list(tk_send('items')) + end + + def remove(*wins) + tk_send('remove', *wins) + self + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/passwddlg.rb new file mode 100644 index 0000000000..0b635d97bb --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressbar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressbar.rb new file mode 100644 index 0000000000..0253ce2ada --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressdlg.rb new file mode 100644 index 0000000000..fbf00f3b00 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/progressdlg.rb @@ -0,0 +1,54 @@ +# +# 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 +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb new file mode 100644 index 0000000000..a3986681a5 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb @@ -0,0 +1,34 @@ +# +# 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')) + win.instance_eval(&b) if b + win + end + + def see(win, vert=None, horiz=None) + tk_send_without_enc('see', win, vert, horiz) + self + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb new file mode 100644 index 0000000000..e9e53235b7 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb @@ -0,0 +1,32 @@ +# +# 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 get_frame(&b) + win = window(tk_send_without_enc('getframe')) + win.instance_eval(&b) if b + win + end + + def set_widget(win) + tk_send_without_enc('setwidget', win) + self + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollview.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/scrollview.rb new file mode 100644 index 0000000000..0546af2c43 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectcolor.rb new file mode 100644 index 0000000000..742a84cd84 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectcolor.rb @@ -0,0 +1,45 @@ +# +# 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 + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectfont.rb new file mode 100644 index 0000000000..478787602a --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/selectfont.rb @@ -0,0 +1,85 @@ +# +# 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 __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' + 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' + tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys)) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/separator.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/separator.rb new file mode 100644 index 0000000000..d9c3458e51 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/spinbox.rb new file mode 100644 index 0000000000..ca4c046e5c --- /dev/null +++ b/ruby_1_8_5/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 < TkEntry + 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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/statusbar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/statusbar.rb new file mode 100644 index 0000000000..df16e4c0b7 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/statusbar.rb @@ -0,0 +1,46 @@ +# +# 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' + end + private :__boolval_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')) + win.instance_eval(&b) if b + win + end + + def items + list(tk_send('items')) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/titleframe.rb new file mode 100644 index 0000000000..f519490430 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/titleframe.rb @@ -0,0 +1,27 @@ +# +# 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')) + win.instance_eval(&b) if b + win + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/tree.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/tree.rb new file mode 100644 index 0000000000..e7178debe2 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/tree.rb @@ -0,0 +1,434 @@ +# +# 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 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 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 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(@tree.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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless TreeNode_TBL[tpath] + TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id + 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 + @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_) + TreeNode_ID[1].succ! + end + + 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(key) + @tree.itemcget(@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/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/widget.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/widget.rb new file mode 100644 index 0000000000..568e503a8b --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/bwidget/widget.rb @@ -0,0 +1,113 @@ +# +# 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(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)) + win.instance_eval(&b) if b + 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(win, subwidget) + tk_call('Widget::subcget', 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/ruby_1_8_5/ext/tk/lib/tkextlib/itcl.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/itcl.rb new file mode 100644 index 0000000000..1d6ecf04f2 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/itcl/incr_tcl.rb new file mode 100644 index 0000000000..07abf3a7bf --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/itcl/incr_tcl.rb @@ -0,0 +1,172 @@ +# +# 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, '00000'.taint].freeze + ITCL_OBJ_TBL = {}.taint + + def initialize(*args) + if (@klass = self.class::ITCL_CLASSNAME).empty? + fail RuntimeError, 'unknown itcl class (abstract class?)' + end + @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_) + @path = @id + Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ! + 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/ruby_1_8_5/ext/tk/lib/tkextlib/itcl/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/itcl/setup.rb new file mode 100644 index 0000000000..5be0588703 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/itk.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/itk.rb new file mode 100644 index 0000000000..7492bd3eb4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/itk/incr_tk.rb new file mode 100644 index 0000000000..0626536e36 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/itk/incr_tk.rb @@ -0,0 +1,428 @@ +# +# 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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear } + + def self.id2obj(master, id) + if master.kind_of?(TkObject) + master = master.path + else + master = master.to_s + end + return id unless ComponentID_TBL.key?(master) + (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id + 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 + component = Itk_Component_ID.join(TkCore::INTERP._ip_id_) + Itk_Component_ID[1].succ! + end + + 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[@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/ruby_1_8_5/ext/tk/lib/tkextlib/itk/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/itk/setup.rb new file mode 100644 index 0000000000..e47b64adae --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets.rb new file mode 100644 index 0000000000..ebd4cf7507 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb new file mode 100644 index 0000000000..a055e07ac9 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb @@ -0,0 +1,119 @@ +# +# 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 itemcget + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/calendar.rb new file mode 100644 index 0000000000..0152f8593a --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/calendar.rb @@ -0,0 +1,106 @@ +# +# 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 ] + _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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb new file mode 100644 index 0000000000..fa5e90ad05 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb new file mode 100644 index 0000000000..bbf507677c --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/checkbox.rb new file mode 100644 index 0000000000..abd23299a8 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/checkbox.rb @@ -0,0 +1,116 @@ +# +# 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 itemcget + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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(idx) + simplelist(tk_call(@path, 'get', index(idx))).collect{|id| + Tk::Itk::Component.id2obj(id) + } + 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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/combobox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/combobox.rb new file mode 100644 index 0000000000..a6d54d78fa --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dateentry.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dateentry.rb new file mode 100644 index 0000000000..0a8897f50d --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/datefield.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/datefield.rb new file mode 100644 index 0000000000..632f3334dc --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialog.rb new file mode 100644 index 0000000000..8540eae1b5 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb new file mode 100644 index 0000000000..d6c668621d --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb @@ -0,0 +1,119 @@ +# +# 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 itemcget + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb new file mode 100644 index 0000000000..9bc063ba69 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/entryfield.rb new file mode 100644 index 0000000000..6aa933ce06 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/entryfield.rb @@ -0,0 +1,166 @@ +# +# 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 + ] + _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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extbutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extbutton.rb new file mode 100644 index 0000000000..158d9d474a --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb new file mode 100644 index 0000000000..501f4c90a0 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb new file mode 100644 index 0000000000..14388be7c4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/feedback.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/feedback.rb new file mode 100644 index 0000000000..0a25237a24 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb new file mode 100644 index 0000000000..7b331d0b40 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb new file mode 100644 index 0000000000..50f459e56d --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/finddialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/finddialog.rb new file mode 100644 index 0000000000..75e219c37e --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb new file mode 100644 index 0000000000..4cc6aeecbd --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -0,0 +1,309 @@ +# +# 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 ] + _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 + ] + + _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 ] + _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 TkText 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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb new file mode 100644 index 0000000000..77b0e090cd --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb new file mode 100644 index 0000000000..e77e85045d --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb new file mode 100644 index 0000000000..99387710cb --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb new file mode 100644 index 0000000000..4b2541b997 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/menubar.rb new file mode 100644 index 0000000000..dea3d34c2a --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/menubar.rb @@ -0,0 +1,210 @@ +# +# 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 itemcget + alias menuconfigure itemconfigure + alias menuconfiginfo itemconfiginfo + alias current_menuconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagebox.rb new file mode 100644 index 0000000000..2bbbec7666 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagebox.rb @@ -0,0 +1,91 @@ +# +# 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 itemcget + alias typeconfigure itemconfigure + alias typeconfiginfo itemconfiginfo + alias current_typeconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb new file mode 100644 index 0000000000..c19b83e517 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/notebook.rb new file mode 100644 index 0000000000..0f9d713ea1 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/notebook.rb @@ -0,0 +1,168 @@ +# +# 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 itemcget + alias pageconfigure itemconfigure + alias pageconfiginfo itemconfiginfo + alias current_pageconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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 + window(tk_send_without_enc('view')) + 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(*idxs) + view('scroll', *idxs) + end + alias xview_scroll view_scroll + alias yview_scroll view_scroll +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb new file mode 100644 index 0000000000..0c74440be7 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb new file mode 100644 index 0000000000..035df0a5b8 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb @@ -0,0 +1,132 @@ +# +# 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 itemcget + alias paneconfigure itemconfigure + alias paneconfiginfo itemconfiginfo + alias current_paneconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb new file mode 100644 index 0000000000..620b14b5d5 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb new file mode 100644 index 0000000000..c21007ca6c --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/radiobox.rb new file mode 100644 index 0000000000..d4316754f2 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/radiobox.rb @@ -0,0 +1,116 @@ +# +# 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 itemcget + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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(idx) + simplelist(tk_call(@path, 'get', index(idx))).collect{|id| + Tk::Itk::Component.id2obj(id) + } + 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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb new file mode 100644 index 0000000000..bddef50841 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb new file mode 100644 index 0000000000..407c8f2aad --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -0,0 +1,347 @@ +# +# 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.methods.include?(id.id2name) + @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 paramters + 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) + if TkcItem::CItemID_TBL[self.path] + find('withtag', *args).each{|item| + if item.kind_of?(TkcItem) + TkcItem::CItemID_TBL[self.path].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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb new file mode 100644 index 0000000000..8b47460357 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb new file mode 100644 index 0000000000..9b69ef07fe --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb new file mode 100644 index 0000000000..cd1f6f0f79 --- /dev/null +++ b/ruby_1_8_5/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.methods.include?(id.id2name) + @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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb new file mode 100644 index 0000000000..fdafc8dc7f --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb @@ -0,0 +1,538 @@ +# +# 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.methods.include?(id.id2name) + @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(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_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 $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 ::= [] [] + # If 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 ::= [] [] + # If 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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb new file mode 100644 index 0000000000..eef093d314 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb new file mode 100644 index 0000000000..bb81fcca5e --- /dev/null +++ b/ruby_1_8_5/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 TkListbox ( 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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb new file mode 100644 index 0000000000..ab790e97a6 --- /dev/null +++ b/ruby_1_8_5/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 TkListbox ( 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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/shell.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/shell.rb new file mode 100644 index 0000000000..dabf2e6f25 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spindate.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spindate.rb new file mode 100644 index 0000000000..2c98eb4629 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinint.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinint.rb new file mode 100644 index 0000000000..5eb944d081 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinner.rb new file mode 100644 index 0000000000..174b9bd506 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -0,0 +1,150 @@ +# +# 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 + ] + _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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spintime.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/spintime.rb new file mode 100644 index 0000000000..0ff683ab56 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb new file mode 100644 index 0000000000..0d9715f87b --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb @@ -0,0 +1,169 @@ +# +# 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 itemcget + alias pageconfigure itemconfigure + alias pageconfiginfo itemconfiginfo + alias current_pageconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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 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 + window(tk_send_without_enc('view')) + 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) + view('scroll', *index) + end + alias xview_scroll view_scroll + alias yview_scroll view_scroll +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabset.rb new file mode 100644 index 0000000000..54e56d0514 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/tabset.rb @@ -0,0 +1,99 @@ +# +# 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 itemcget + alias tabconfigure itemconfigure + alias tabconfiginfo itemconfiginfo + alias current_tabconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :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 +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/timeentry.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/timeentry.rb new file mode 100644 index 0000000000..588da77dc8 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/timefield.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/timefield.rb new file mode 100644 index 0000000000..28e1504797 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/toolbar.rb new file mode 100644 index 0000000000..17cfa62156 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/watch.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/iwidgets/watch.rb new file mode 100644 index 0000000000..ab2b687cf9 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/pkg_checker.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/pkg_checker.rb new file mode 100755 index 0000000000..5002ed7ff8 --- /dev/null +++ b/ruby_1_8_5/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 directry that this command exists.\n" + print "\tAvailable options are \n" + print "\t -l : Add dir to $LOAD_PATH\n" + print "\t (If dir == '/tkextlib', add 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/ruby_1_8_5/ext/tk/lib/tkextlib/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/setup.rb new file mode 100644 index 0000000000..12867e8f9c --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib.rb new file mode 100644 index 0000000000..c6138f4275 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib.rb @@ -0,0 +1,90 @@ +# +# 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:: ctext + autoload :CText, 'tkextlib/tcllib/ctext' + + # package:: getstring + autoload :GetString_Dialog, 'tkextlib/tcllib/getstring' + + # package:: history + autoload :History, 'tkextlib/tcllib/history' + + # package:: datefield + autoload :Datefield, 'tkextlib/tcllib/datefield' + autoload :DateField, 'tkextlib/tcllib/datefield' + + # package:: ico + autoload :ICO, 'tkextlib/tcllib/ico' + + # package:: ipentry + autoload :IP_Entry, 'tkextlib/tcllib/ip_entry' + autoload :IPEntry, 'tkextlib/tcllib/ip_entry' + + # package:: swaplist + autoload :Swaplist_Dialog, 'tkextlib/tcllib/swaplist' + + # package:: Plotchart + autoload :Plotchart, 'tkextlib/tcllib/plotchart' + + # 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 :Wdiget, 'tkextlib/tcllib/widget' + end +end + +if $VERBOSE && !err.empty? + warn("Warning: some sub-packages are failed to require : " + err) +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/README b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/README new file mode 100644 index 0000000000..953239befa --- /dev/null +++ b/ruby_1_8_5/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. + +--------------------------------- +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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/autoscroll.rb new file mode 100644 index 0000000000..6940a9174c --- /dev/null +++ b/ruby_1_8_5/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 TkScrollbar + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ctext.rb new file mode 100644 index 0000000000..70a45dd8e7 --- /dev/null +++ b/ruby_1_8_5/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 < TkText + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/cursor.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/cursor.rb new file mode 100644 index 0000000000..9bb828e8dd --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/datefield.rb new file mode 100644 index 0000000000..bd84488101 --- /dev/null +++ b/ruby_1_8_5/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 < TkEntry + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/dialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/dialog.rb new file mode 100644 index 0000000000..825621b5a1 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/getstring.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/getstring.rb new file mode 100644 index 0000000000..bf5e54e8cf --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/getstring.rb @@ -0,0 +1,131 @@ +# +# 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(slot) + slot = slot.to_s + if slot == 'text' + @text + else + @keys[slot] + 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 + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/history.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/history.rb new file mode 100644 index 0000000000..a01a4ebfcc --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ico.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ico.rb new file mode 100644 index 0000000000..3beeb11a4d --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ico.rb @@ -0,0 +1,114 @@ +# +# 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.get(file, index, keys=nil) + tk_call_without_enc('::ico::getIcon', file, index, *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 + @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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ip_entry.rb new file mode 100644 index 0000000000..8c9e0bd683 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ip_entry.rb @@ -0,0 +1,66 @@ +# +# 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 < TkEntry + 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 + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/panelframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/panelframe.rb new file mode 100644 index 0000000000..2a4562e779 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/panelframe.rb @@ -0,0 +1,72 @@ +# +# 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) + end + def remove_destroy(*wins) + tk_send('remove', '-destroy', *wins) + end + alias delete remove_destroy + + def items + simplelist(tk_send('items')).collect!{|w| window(w)} + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/plotchart.rb new file mode 100644 index 0000000000..f5f344ceb3 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -0,0 +1,865 @@ +# +# 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') + +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.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::coordsToPixel', w.path, x, y)) + end + + def self.determine_scale(w, xmax, ymax) + tk_call_without_enc('::Plotchart::determineScale', w.path, xmax, ymax) + 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_without_enc(@chart, 'xconfig', + "-#{key}", _get_eval_enc_str(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_without_enc(@chart, 'yconfig', + "-#{key}", _get_eval_enc_str(value)) + end + 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 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::coordsToPixel', @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 < TkCanvas + 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?(TkCanvas) + @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.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_without_enc(@chart, 'contourlines', xcrd, ycrd, vals, clss) + self + end + + def contourfill(xcrd, ycrd, vals, klasses=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_without_enc(@chart, 'contourfill', xcrd, ycrd, vals, clss) + self + end + + def contourbox(xcrd, ycrd, vals, klasses=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_without_enc(@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_without_enc(@chart, 'dataconfig', series, + "-#{key}", _get_eval_enc_str(value)) + end + end + end + + ############################ + class Stripchart < XYPlot + TkCommandNames = [ + 'canvas'.freeze, + '::Plotchart::createStripchart'.freeze + ].freeze + end + + ############################ + class PolarPlot < TkCanvas + 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?(TkCanvas) + @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.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', series, *hash_kv(key, true)) + else + tk_call_without_enc(@chart, 'dataconfig', series, + "-#{key}", _get_eval_enc_str(value)) + end + end + end + Polarplot = PolarPlot + + ############################ + class IsometricPlot < TkCanvas + 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?(TkCanvas) + @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 < TkCanvas + 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?(TkCanvas) + @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_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 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 Piechart < TkCanvas + include ChartMethod + + TkCommandNames = [ + 'canvas'.freeze, + '::Plotchart::createPiechart'.freeze + ].freeze + + def initialize(*args) # args := ([parent] [, keys]) + if args[0].kind_of?(TkCanvas) + 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_without_enc(@chart, 'plot', dat.flatten) + self + end + end + + ############################ + class Barchart < TkCanvas + 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?(TkCanvas) + @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.delete(@path) + end + + def plot(series, dat, col=None) + tk_call_without_enc(@chart, 'plot', series, dat, col) + self + end + + def colours(*cols) + # set the colours to be used + tk_call_without_enc(@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 Timechart < TkCanvas + 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?(TkCanvas) + @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_without_enc(@chart, 'period', txt, time_begin, time_end, col) + self + end + + def milestone(txt, time, col=None) + tk_call_without_enc(@chart, 'milestone', txt, time, col) + self + end + + def vertline(txt, time) + tk_call_without_enc(@chart, 'vertline', txt, time) + self + end + end + + ############################ + class Gnattchart < TkCanvas + include ChartMethod + + TkCommandNames = [ + 'canvas'.freeze, + '::Plotchart::createGnattchart'.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") + # 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 + + if args[0].kind_of?(Fixnum) + @text_width = args.shift + else + @text_width = None + end + + super(*args) # create canvas widget + else + parent = args.shift + + @time_begin = args.shift + @time_end = args.shift + @items = args.shift + + if args[0].kind_of?(Fixnum) + @text_width = args.shift + else + @text_width = None + end + + if parent.kind_of?(TkCanvas) + @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, @text_width) + end + private :_create_chart + + def task(txt, time_begin, time_end, completed=0.0) + list(tk_call_without_enc(@chart, 'task', txt, time_begin, time_end, + completed)).collect!{|id| + TkcItem.id2obj(self, id) + } + end + + def milestone(txt, time, col=None) + tk_call_without_enc(@chart, 'milestone', txt, time, col) + self + end + + def vertline(txt, time) + tk_call_without_enc(@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_without_enc(@chart, 'connect', from_task, to_task) + self + end + + def summary(txt, tasks) + tasks = array2tk_list(tasks) if tasks.kind_of?(Array) + tk_call_without_enc(@chart, 'summary', tasks) + self + end + + def color_of_part(keyword, newcolor) + tk_call_without_enc(@chart, 'color', keyword, newcolor) + self + end + + def font_of_part(keyword, newfont) + tk_call_without_enc(@chart, 'font', keyword, newfont) + self + end + end + + ############################ + class PlotSeries < TkObject + SeriesID_TBL = TkCore::INTERP.create_table + Series_ID = ['series'.freeze, '00000'.taint].freeze + TkCore::INTERP.init_ip_env{ SeriesID_TBL.clear } + + def self.id2obj(chart, id) + path = chart.path + return id unless SeriesID_TBL[path] + SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id + end + + def initialize(chart, keys=nil) + @parent = @chart_obj = chart + @ppath = @chart_obj.path + @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_) + # SeriesID_TBL[@id] = self + SeriesID_TBL[@ppath] = {} unless SeriesID_TBL[@ppath] + SeriesID_TBL[@ppath][@id] = self + Series_ID[1].succ! + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ruler.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/ruler.rb new file mode 100644 index 0000000000..88ffb2c912 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/screenruler.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/screenruler.rb new file mode 100644 index 0000000000..1b4067e2f0 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/scrollwin.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/scrollwin.rb new file mode 100644 index 0000000000..717728e34a --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/style.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/style.rb new file mode 100644 index 0000000000..dac6916e46 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/superframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/superframe.rb new file mode 100644 index 0000000000..35da37efbf --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/swaplist.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/swaplist.rb new file mode 100644 index 0000000000..97de0a27c1 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/swaplist.rb @@ -0,0 +1,147 @@ +# +# 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(slot) + slot = slot.to_s + if slot == 'complete_list' + @complete_list + elsif slot == 'selected_list' + @selected_list + else + @keys[slot] + 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 + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist.rb new file mode 100644 index 0000000000..42435a1971 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist.rb @@ -0,0 +1,27 @@ +# +# 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') +end + +if Tk::Tcllib::Tablelist_usingTile + # with Tile + require 'tkextlib/tcllib/tablelist_tile' + +else + # without Tile + + # TkPackage.require('Tablelist', '4.2') + TkPackage.require('Tablelist') + + requrie 'tkextlib/tcllib/tablelist_core' +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb new file mode 100644 index 0000000000..a939a58331 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb @@ -0,0 +1,770 @@ +# +# 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(tagOrId, option) + itemcget(['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 cell_cget + alias cellconfigure cell_configure + alias cellconfiginfo cell_configinfo + alias current_cellconfiginfo current_cell_configinfo + + def column_cget(tagOrId, option) + itemcget(['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 column_cget + alias columnconfigure column_configure + alias columnconfiginfo column_configinfo + alias current_columnconfiginfo current_column_configinfo + + def row_cget(tagOrId, option) + itemcget(['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 row_cget + alias rowconfigure row_configure + alias rowconfiginfo row_configinfo + alias current_rowconfiginfo current_row_configinfo + + private :itemcget, :itemconfigure + private :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() + [ + 'forceeditendcommand', 'movablecolumns', 'movablerows', + 'protecttitlecolumns', 'resizablecolumns', + 'showarrow', 'showlabels', 'showseparators' + ] + end + private :__boolval_optkeys + + def __listval_optkeys + super() + ['columns'] + 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)}) + 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 + }) + 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'] + end + end + private :__item_strval_optkeys + + def __item_boolval_optkeys(id) + super(id) + [ + 'editable', 'hide', 'resizable', 'showarrow', 'stretchable', + ] + 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 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 columncount + number(tk_send('columncount')) + end + + def columnindex(idx) + number(tk_send('columnindex', _to_idx(idx))) + end + + 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 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 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 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 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 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 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_sortByColumn_cmd = '::tablelist::sortByColumn' + + 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 sortcolumn + idx = num_or_str(tk_send('sortcolum')) + (idx.kind_of?(Fixnum) && idx < 0)? nil: idx + end + + def sortorder + tk_send('sortorder') + 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 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 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 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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb new file mode 100644 index 0000000000..0cb4eb735d --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb @@ -0,0 +1,25 @@ +# +# 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 + Tablelist_Tile = Tablelist + TableList_Tile = Tablelist + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb new file mode 100644 index 0000000000..92dde65ce7 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb @@ -0,0 +1,308 @@ +# +# 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[@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[@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[@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/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tooltip.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tooltip.rb new file mode 100644 index 0000000000..4301b39fd3 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/tooltip.rb @@ -0,0 +1,95 @@ +# +# 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 + 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.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_without_enc('::tooltip::tooltip', widget.path, *args) + end + + def self.erase(widget) + tk_call_without_enc('::tooltip::tooltip', widget.path, '') + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/widget.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/widget.rb new file mode 100644 index 0000000000..ed69f67ce6 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tcllib/widget.rb @@ -0,0 +1,48 @@ +# +# 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 + end +end + +module Tk::Tcllib::Widget + 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' +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tclx.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tclx.rb new file mode 100644 index 0000000000..3a4ff27644 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tclx/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tclx/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tclx/tclx.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tclx/tclx.rb new file mode 100644 index 0000000000..5a908fcd0b --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tile.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile.rb new file mode 100644 index 0000000000..690f93f029 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile.rb @@ -0,0 +1,225 @@ +# +# Tile theme engin (tile widget set) support +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' + +# 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') +verstr = TkPackage.require('tile') +ver = verstr.split('.') +if ver[0].to_i == 0 && 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[0].to_i == 0 && 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 +else + # version 0.7 or later + module Tk + module Tile + USE_TILE_NAMESPACE = false + USE_TTK_NAMESPACE = true + TILE_SPEC_VERSION_ID = 7 + end + end +end + +# autoload +module Tk + module Tile + TkComm::TkExtlibAutoloadModule.unshift(self) + + PACKAGE_NAME = 'tile'.freeze + def self.package_name + PACKAGE_NAME + end + + def self.package_version + begin + TkPackage.require('tile') + rescue + '' + end + end + + def self.__Import_Tile_Widgets__! + Tk.tk_call('namespace', 'import', '-force', 'ttk::*') + end + + def self.load_images(imgdir, pat=TkComm::None) + images = Hash[*TkComm.simplelist(Tk.tk_call('::tile::LoadImages', + imgdir, pat))] + images.keys.each{|k| + images[k] = TkPhotoImage.new(:imagename=>images[k], + :without_creating=>true) + } + + images + end + + def self.style(*args) + args.map!{|arg| TkComm._get_eval_string(arg)}.join('.') + end + + module KeyNav + def self.enableMnemonics(w) + Tk.tk_call('::keynav::enableMnemonics', w) + end + def self.defaultButton(w) + Tk.tk_call('::keynav::defaultButton', w) + end + end + + module Font + Default = 'TkDefaultFont' + Text = 'TkTextFont' + Heading = 'TkHeadingFont' + Caption = 'TkCaptionFont' + Tooltip = 'TkTooltipFont' + + Fixed = 'TkFixedFont' + Menu = 'TkMenuFont' + SmallCaption = 'TkSmallCaptionFont' + Icon = '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 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 + + def state(state=nil) + if state + tk_send('state', state) + else + list(tk_send('state')) + end + 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 :TLabel, 'tkextlib/tile/tlabel' + autoload :Label, 'tkextlib/tile/tlabel' + + 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 :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 :TSeparator, 'tkextlib/tile/tseparator' + autoload :Separator, 'tkextlib/tile/tseparator' + + autoload :TSquare, 'tkextlib/tile/tsquare' + autoload :Square, 'tkextlib/tile/tsquare' + + autoload :Treeview, 'tkextlib/tile/treeview' + + autoload :Style, 'tkextlib/tile/style' + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/dialog.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/dialog.rb new file mode 100644 index 0000000000..f8ddf62598 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/dialog.rb @@ -0,0 +1,84 @@ +# +# 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 + +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')) + end + + def cget(slot) + @keys[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 + @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/ruby_1_8_5/ext/tk/lib/tkextlib/tile/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tile/style.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/style.rb new file mode 100644 index 0000000000..485a36d7d6 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/style.rb @@ -0,0 +1,103 @@ +# +# 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 + 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('style', sub_cmd, style, *hash_kv(keys)) + else + tk_call('style', 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 + tk_call('style', 'map', style, *hash_kv(keys)) + else + tk_call('style', 'map', style) + end + 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('style', 'layout', style, spec) + else + _style_layout(list(tk_call('style', 'layout', style))) + end + end + + def element_create(name, type, *args) + tk_call('style', 'element', 'create', name, type, *args) + end + + def element_names() + list(tk_call('style', 'element', 'names')) + end + + def element_options(elem) + simplelist(tk_call('style', 'element', 'options', elem)) + end + + def theme_create(name, keys=nil) + if keys && keys != None + tk_call('style', 'theme', 'create', name, *hash_kv(keys)) + else + tk_call('style', 'theme', 'create', name) + end + end + + def theme_settings(name, cmd=nil, &b) + cmd = Proc.new(&b) if !cmd && b + tk_call('style', 'theme', 'settings', name, cmd) + end + + def theme_names() + list(tk_call('style', 'theme', 'names')) + end + + def theme_use(name) + tk_call('style', 'theme', 'use', name) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tbutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tbutton.rb new file mode 100644 index 0000000000..1142a27100 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tbutton.rb @@ -0,0 +1,30 @@ +# +# tbutton widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TButton < TkButton + end + Button = TButton + end +end + +class Tk::Tile::TButton < TkButton + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcheckbutton.rb new file mode 100644 index 0000000000..fce799683d --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcheckbutton.rb @@ -0,0 +1,32 @@ +# +# tcheckbutton widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TCheckButton < TkCheckButton + end + TCheckbutton = TCheckButton + CheckButton = TCheckButton + Checkbutton = TCheckButton + end +end + +class Tk::Tile::TCheckButton < TkCheckButton + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tcombobox.rb new file mode 100644 index 0000000000..c63ab94dbe --- /dev/null +++ b/ruby_1_8_5/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', idx)) + end + def current=(idx) + tk_send_without_enc('current', idx) + end + + def identify(x, y) + tk_send_without_enc('identify', x, y) + end + + def set(val) + tk_send('set', val) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tentry.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tentry.rb new file mode 100644 index 0000000000..4d57ce7756 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tentry.rb @@ -0,0 +1,40 @@ +# +# tentry widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TEntry < TkEntry + end + Entry = TEntry + end +end + +class Tk::Tile::TEntry < TkEntry + 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 __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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tframe.rb new file mode 100644 index 0000000000..691c9c42af --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tframe.rb @@ -0,0 +1,30 @@ +# +# tframe widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TFrame < TkFrame + end + Frame = TFrame + end +end + +class Tk::Tile::TFrame < TkFrame + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabel.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabel.rb new file mode 100644 index 0000000000..4111d1906a --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabel.rb @@ -0,0 +1,30 @@ +# +# tlabel widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TLabel < TkLabel + end + Label = TLabel + end +end + +class Tk::Tile::TLabel < TkLabel + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabelframe.rb new file mode 100644 index 0000000000..8981232b25 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tlabelframe.rb @@ -0,0 +1,30 @@ +# +# 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 + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tmenubutton.rb new file mode 100644 index 0000000000..4b81fa1c81 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tmenubutton.rb @@ -0,0 +1,30 @@ +# +# tmenubutton widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TMenubutton < TkMenubutton + end + Menubutton = TMenubutton + end +end + +class Tk::Tile::TMenubutton < TkMenubutton + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tnotebook.rb new file mode 100644 index 0000000000..abaed8ee9c --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tnotebook.rb @@ -0,0 +1,110 @@ +# +# 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 + [] + end + private :__item_listval_optkeys + + def __item_methodcall_optkeys # { key=>method, ... } + {} + end + private :__item_listval_optkeys + + #alias tabcget itemcget + alias tabconfigure itemconfigure + alias tabconfiginfo itemconfiginfo + alias current_tabconfiginfo current_itemconfiginfo + + def tabcget(tagOrId, option) + tabconfigure(tagOrId, option)[-1] + 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_without_enc('add', _epath(child), *hash_kv(keys)) + else + tk_send_without_enc('add', _epath(child)) + end + self + end + + def forget(idx) + tk_send('forget', idx) + self + 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 tabs + list(tk_send('tabs')) + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tpaned.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tpaned.rb new file mode 100644 index 0000000000..11178b19d3 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tpaned.rb @@ -0,0 +1,188 @@ +# +# tpaned widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TPaned < TkWindow + end + Paned = TPaned + end +end + +class Tk::Tile::TPaned < TkWindow + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::paned'.freeze].freeze + 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(win, keys) + win = _epath(win) + tk_send_without_enc('add', win, *hash_kv(keys)) + 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(pane, slot) + pane = _epath(pane) + tk_tcl2ruby(tk_send_without_enc('pane', pane, "-#{slot}")) + 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 identify(x, y) + list(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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tprogressbar.rb new file mode 100644 index 0000000000..36c1c75c23 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tprogressbar.rb @@ -0,0 +1,53 @@ +# +# 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tradiobutton.rb new file mode 100644 index 0000000000..e2f614cb97 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tradiobutton.rb @@ -0,0 +1,32 @@ +# +# tradiobutton widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TRadioButton < TkRadioButton + end + TRadiobutton = TRadioButton + RadioButton = TRadioButton + Radiobutton = TRadioButton + end +end + +class Tk::Tile::TRadioButton < TkRadioButton + 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/treeview.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/treeview.rb new file mode 100644 index 0000000000..d3ffbbfa6b --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/treeview.rb @@ -0,0 +1,280 @@ +# +# treeview widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class Treeview < TkWindow + end + + module TreeviewConfig + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, id[0], id[1]] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, id[0], id[1]] + end + private :__item_config_cmd + + def __item_numstrval_optkeys(id) + case id[0] + when :item, 'item' + ['width'] + when :column, 'column' + super(id[1]) + when :heading, 'heading' + 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 :heading, 'heading' + 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]) + 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' + [] + end + end + private :__item_listval_optkeys + + alias __itemcget itemcget + alias __itemconfigure itemconfigure + alias __itemconfiginfo itemconfiginfo + alias __current_itemconfiginfo current_itemconfiginfo + + private :__itemcget, :__itemconfigure + private :__itemconfiginfo, :__current_itemconfiginfo + + # Treeview Item + def itemcget(tagOrId, option) + __itemcget([: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(tagOrId, option) + __itemcget([: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 columncget + alias column_configure columnconfigure + alias column_configinfo columnconfiginfo + alias current_column_configinfo current_columnconfiginfo + + # Treeview Heading + def headingcget(tagOrId, option) + __itemcget([:heading, tagOrId], option) + end + def headingconfigure(tagOrId, slot, value=None) + __itemconfigure([:heading, tagOrId], slot, value) + 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 headingcget + alias heading_configure headingconfigure + alias heading_configinfo headingconfiginfo + alias current_heading_configinfo current_headingconfiginfo + end + 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 self.style(*args) + [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.') + end + + def tagid(id) + if id.kind_of?(Array) + [id[0], _get_eval_string(id[1])] + else + _get_eval_string(id) + end + end + + def children(item) + simplelist(tk_send_without_enc('children', item)) + 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 = None) + tk_send('focus', item) + end + + def identify(x, y) + ret = simplelist(tk_send('identify', x, y)) + case ret[0] + when 'heading', 'separator', 'cell' + ret[-1] = num_or_str(ret[-1]) + end + end + + def index(item) + number(tk_send('index', item)) + end + + def insert(parent, idx, keys={}) + keys = _symbolkey2str(keys) + id = keys.delete('id') + if id + tk_send('insert', parent, idx, '-id', id, *hash_kv(keys)) + else + tk_send('insert', parent, idx, *hash_kv(keys)) + end + self + 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) + tk_send('next', item) + end + + def parent(item) + tk_send('parent', item) + end + + def prev(item) + tk_send('prev', item) + end + + def see(item) + tk_send('see', item) + self + end + + def selection + simplelist(tk_send('selection')) + 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 + def get(item, col) + tk_send('set', item, col) + end + def set(item, col, value) + tk_send('set', item, col, value) + self + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscale.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscale.rb new file mode 100644 index 0000000000..7ec72e3515 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscale.rb @@ -0,0 +1,50 @@ +# +# tscale & tprogress widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TScale < TkScale + end + Scale = TScale + + class TProgress < TScale + end + Progress = TProgress + end +end + +class Tk::Tile::TScale < TkScale + 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 +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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscrollbar.rb new file mode 100644 index 0000000000..bd49ae18e3 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tscrollbar.rb @@ -0,0 +1,30 @@ +# +# tscrollbar widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TScrollbar < TkScrollbar + end + Scrollbar = TScrollbar + end +end + +class Tk::Tile::TScrollbar < TkScrollbar + 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 +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tseparator.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tseparator.rb new file mode 100644 index 0000000000..ca731d4e5b --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tseparator.rb @@ -0,0 +1,30 @@ +# +# 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 diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tsquare.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tile/tsquare.rb new file mode 100644 index 0000000000..600b55e4e7 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND.rb new file mode 100644 index 0000000000..5d52e34418 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/shape.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/shape.rb new file mode 100644 index 0000000000..570c93b0d9 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/shape.rb @@ -0,0 +1,123 @@ +# +# 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 + def self.package_version + Tk.tk_call('set', 'shape_version') + end + alias shape_version package_version + + def self.package_patchlevel + Tk.tk_call('set', 'shape_patchlevel') + end + alias shape_patchlevel package_patchlevel + + def self.version + tk_call('shape', 'version') + end + alias xshape_version version + + ############################ + + 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 ? srckind ?arg ...? + tk_call('shape', 'set', @path, *(_parse_shapespec_param(args))) + self + end + + def shape_update(op, *args) # ?kind? ?offset ? 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/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/tkdnd.rb new file mode 100644 index 0000000000..a040532eb6 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tkDND/tkdnd.rb @@ -0,0 +1,164 @@ +# +# 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 + ] + + # 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 = [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/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML.rb new file mode 100644 index 0000000000..5fddde72ff --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb new file mode 100644 index 0000000000..8527f61df1 --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb @@ -0,0 +1,444 @@ +# +# 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.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 + return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath] + + widgetname = keys.delete('widgetname') + if widgetname =~ /^(.*)\.[^.]+$/ + ppath2 = $1 + if ppath2[0] != ?. + ppath2 = ppath + '.' + ppath2 + end + 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[@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/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkHTML/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg.rb new file mode 100644 index 0000000000..c01359d3ef --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/README b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/README new file mode 100644 index 0000000000..65d36365d0 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/bmp.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/bmp.rb new file mode 100644 index 0000000000..ea90181aa3 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/gif.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/gif.rb new file mode 100644 index 0000000000..d542d47561 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ico.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/ico.rb new file mode 100644 index 0000000000..e79bdf45e9 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/jpeg.rb new file mode 100644 index 0000000000..2126120161 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pcx.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pcx.rb new file mode 100644 index 0000000000..6831f4d35b --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tkimg/pixmap.rb new file mode 100644 index 0000000000..bd1b870af7 --- /dev/null +++ b/ruby_1_8_5/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 TkPixmapImagemethod, ... } + super(id).update('window'=>proc{|v| window(v)}) + end + private :__item_val2ruby_optkeys + + def tag_cget(tagOrId, option) + itemcget(['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(tagOrId, option) + itemcget(['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, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo +end + +##################################################### + +class Tk::TkTable::CellTag + include TkTreatTagFont + + CellTagID_TBL = TkCore::INTERP.create_table + CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ CellTagID_TBL.clear } + + def self.id2obj(table, id) + tpath = table.path + return id unless CellTagID_TBL[tpath] + CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id + end + + def initialize(parent, keys=nil) + @parent = @t = parent + @tpath - parent.path + @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_) + CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath] + CellTagID_TBL[@tpath][@id] = self + CellTag_ID[1].succ! + configure(keys) if keys + end + + def id + @id + end + + def destroy + tk_call(@tpath, 'tag', 'delete', @id) + 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(key) + @t.tag_cget(@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) + if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name] + cell = CellTagID_TBL[parent.path][name] + cell.configure(keys) if keys + return cell + else + super(parent, name, keys) + end + end + + def initialize(parent, name, keys=nil) + @parent = @t = parent + @tpath - parent.path + @path = @id = name + CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath] + CellTagID_TBL[@tpath][@id] = self + configure(keys) if keys + 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.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 + ] + + _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 + ] + + _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 + ] + + _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 + ] + + _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) + 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)) + 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/ruby_1_8_5/ext/tk/lib/tkextlib/tktrans.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tktrans.rb new file mode 100644 index 0000000000..c5de5be5e6 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/tktrans/tktrans.rb new file mode 100644 index 0000000000..665c57af0c --- /dev/null +++ b/ruby_1_8_5/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 TkRoot + 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 TkToplevel + 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/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl.rb new file mode 100644 index 0000000000..1944fb83e3 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb new file mode 100644 index 0000000000..12f7cffabf --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -0,0 +1,2311 @@ +# +# 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>, , ] + 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_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 + ] + + # 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'] + elsif id == 'dragimage' + ['visible'] + elsif id == 'marquee' + ['visible'] + elsif id.kind_of?(Array) + case id[0] + when 'item' + ['button', 'visible'] + when 'column' + if id[1] == 'drag' + ['enable'] + else + ['button', 'expand', 'resize', 'squeeze', 'sunken', + 'visible', 'widthhack'] + end + when 'element' + ['draw', 'filled', 'showfocus', 'destroy'] + when 'notify' + ['active'] + when 'style' + ['detach'] + 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_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(tagOrId, option) + itemcget(['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(option) + itemcget(['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(option) + itemcget('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(option) + itemcget('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(tagOrId, option) + itemcget(['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(tagOrId, option) + itemcget(['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(item, column, elem, option) + itemcget([['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(option) + itemcget('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(win, pattern, option) + pattern = "<#{pattern}>" + itemconfigure(['notify', [win, pattern]], option) + 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 + alias current_notify_configinfo notify_configinfo + + def style_cget(tagOrId, option) + itemcget(['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, :itemconfigure + private :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.delete(@path) + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path) + Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path) + 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', + ] + 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) + 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) + 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)} + Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].delete(item) + end + private :_erase_children + + def item_delete(first, last=None) + 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) + tk_send('see', item) + 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) + 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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear} + + def self.id2obj(tree, id) + tpath = tree.path + return id unless Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath] + Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \ + Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id + end + + def initialize(parent, keys={}) + @tree = parent + @tpath = parent.path + + keys = _symbolkey2str(keys) + + @path = @id = + keys.delete('tag') || + Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_) + + keys['tag'] = @id + + unless Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] + Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] = {} + end + Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self + Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ! + + @tree.column_create(keys) + end + + def id + @id + end + + def to_s + @id.to_s.dup + end + + def cget(opt) + @tree.column_cget(@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, '00000'.taint].freeze + TreeCtrlElemTypeToClass = {} + + TkCore::INTERP.init_ip_env{ + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear + } + + def self.type2class(type) + TreeCtrlElemTypeToClass[type] || type + end + + def self.id2obj(tree, id) + tpath = tree.path + return id unless Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath] + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \ + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id] : id + end + + def initialize(parent, type, keys=nil) + @tree = parent + @tpath = parent.path + @type = type.to_s + @path = @id = + Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_) + unless Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] = {} + end + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self + Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ! + + @tree.element_create(@id, @type, keys) + end + + def id + @id + end + + def to_s + @id.dup + end + + def cget(opt) + @tree.element_cget(@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.clear} + + def self.id2obj(tree, id) + tpath = tree.path + return id unless Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath] + Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \ + Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id + end + + def initialize(parent, keys={}) + @tree = parent + @tpath = parent.path + @path = @id = @tree.item_create(keys) + + unless Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] + Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] = {} + end + 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(opt) + @tree.item_cget(@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(opt) + @tree.item_element_cget(@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, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear } + + def self.id2obj(tree, id) + tpath = tree.path + return id unless Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath] + Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \ + Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id + end + + def initialize(parent, keys=nil) + @tree = parent + @tpath = parent.path + @path = @id = + Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_) + unless Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] + Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] = {} + end + Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self + Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ! + + @tree.style_create(@id, keys) + end + + def id + @id + end + + def to_s + @id.dup + end + + def cget(opt) + @tree.style_cget(@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/ruby_1_8_5/ext/tk/lib/tkextlib/trofs.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/trofs.rb new file mode 100644 index 0000000000..5914e5165f --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/trofs/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/trofs/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/trofs/trofs.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/trofs/trofs.rb new file mode 100644 index 0000000000..7a2606a275 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/vu.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu.rb new file mode 100644 index 0000000000..d2234eb2a8 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/vu/bargraph.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/bargraph.rb new file mode 100644 index 0000000000..27ff3c7cd0 --- /dev/null +++ b/ruby_1_8_5/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 -- /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/ruby_1_8_5/ext/tk/lib/tkextlib/vu/charts.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/charts.rb new file mode 100644 index 0000000000..ee4298fa1c --- /dev/null +++ b/ruby_1_8_5/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 -- /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/ruby_1_8_5/ext/tk/lib/tkextlib/vu/dial.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/dial.rb new file mode 100644 index 0000000000..e27a38ae42 --- /dev/null +++ b/ruby_1_8_5/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 -- /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_split_list(tk_send_without_enc('coords')) + else + tk_send_without_enc('coords', val) + self + 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/ruby_1_8_5/ext/tk/lib/tkextlib/vu/pie.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/pie.rb new file mode 100644 index 0000000000..78f3fa54da --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/pie.rb @@ -0,0 +1,235 @@ +# +# ::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 -- /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, '00000'.taint].freeze + TkCore::INTERP.init_ip_env{ SliceID_TBL.clear } + + def self.id2obj(pie, id) + pie_path = pie.path + return id unless SliceID_TBL[pie_path] + SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id + 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 + @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_) + SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath] + SliceID_TBL[@ppath][@id] = self + Pie_Slice_ID[1].succ! + + 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(slot) + @pie.itemcget(@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) + if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name] + return SliceID_TBL[parent.path][name] + else + super(parent, name, *args) + end + end + + def initialize(parent, name, *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 + @path = @id = name.to_s + 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/ruby_1_8_5/ext/tk/lib/tkextlib/vu/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/vu/spinbox.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/vu/spinbox.rb new file mode 100644 index 0000000000..b6499645a3 --- /dev/null +++ b/ruby_1_8_5/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 -- /tkextlib/vu.rb + require 'tkextlib/vu.rb' + + Tk.tk_call('namespace', 'import', '::vu::spinbox') +end + +module Tk + module Vu + Spinbox = TkSpinbox + end +end diff --git a/ruby_1_8_5/ext/tk/lib/tkextlib/winico.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/winico.rb new file mode 100644 index 0000000000..ce7b8eac5c --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/winico/setup.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/winico/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ruby_1_8_5/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/ruby_1_8_5/ext/tk/lib/tkextlib/winico/winico.rb b/ruby_1_8_5/ext/tk/lib/tkextlib/winico/winico.rb new file mode 100644 index 0000000000..c53a3ff48c --- /dev/null +++ b/ruby_1_8_5/ext/tk/lib/tkextlib/winico/winico.rb @@ -0,0 +1,189 @@ +# +# 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.clear } + + def self.id2obj(id) + (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[@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.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| + if Tk::Winico::WinicoID_TBL.key?(id) + Tk::Winico::WinicoID_TBL[id] + else + Tk::Winico.new(nil, nil, id) + end + } ], + nil + ] + + _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(' ')) + # 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(' ')) + # 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 -- cgit v1.2.3