From ce1b23b7a5a496f4b6d3ad4627a161b1dc6945fe Mon Sep 17 00:00:00 2001 From: nagai Date: Thu, 15 Jul 2004 01:18:57 +0000 Subject: * ext/tk/, ext/tcltklib/: bug fix * ext/tk/lib/tk.rb: better operation for SIGINT when processing callbacks. * ext/tk/lib/tk/msgcat.rb: ditto. * ext/tk/lib/tk/variable.rb: ditto. * ext/tk/lib/tk/timer.rb: ditto. * ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd() to define validatecommand methods easier * ext/tk/lib/tk.rb (_genobj_for_tkwidget): support autoload Tk ext classes * ext/tk/lib/tk/canvas.rb and so on: remove the parent widget type check for items (e.g. canvas items; depends on the class) to avoid some troubles on Tk extension widget class definition. * ext/tk/lib/tkextlib/: add Iwidget and TkTable extension support * ext/tk/sample/tkextlib/: add samples of Iwidget and TkTable git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/sample/tkextlib/ICONS/LICENSE.orig | 2 +- ext/tk/sample/tkextlib/ICONS/viewIcons.rb | 2 +- ext/tk/sample/tkextlib/bwidget/LICENSE.orig | 2 +- ext/tk/sample/tkextlib/bwidget/basic.rb | 3 + ext/tk/sample/tkextlib/bwidget/dnd.rb | 3 + ext/tk/sample/tkextlib/bwidget/manager.rb | 3 + ext/tk/sample/tkextlib/bwidget/select.rb | 3 + ext/tk/sample/tkextlib/bwidget/tmpldlg.rb | 3 + ext/tk/sample/tkextlib/bwidget/tree.rb | 3 + .../tkextlib/iwidgets/catalog_demo/LICENSE.orig | 42 ++++++ .../tkextlib/iwidgets/catalog_demo/images/box.xbm | 14 ++ .../iwidgets/catalog_demo/images/close.gif | Bin 0 -> 249 bytes .../tkextlib/iwidgets/catalog_demo/images/copy.gif | Bin 0 -> 269 bytes .../tkextlib/iwidgets/catalog_demo/images/cut.gif | Bin 0 -> 179 bytes .../tkextlib/iwidgets/catalog_demo/images/exit.gif | Bin 0 -> 396 bytes .../tkextlib/iwidgets/catalog_demo/images/find.gif | Bin 0 -> 386 bytes .../tkextlib/iwidgets/catalog_demo/images/help.gif | Bin 0 -> 591 bytes .../tkextlib/iwidgets/catalog_demo/images/line.xbm | 14 ++ .../tkextlib/iwidgets/catalog_demo/images/mag.gif | Bin 0 -> 183 bytes .../tkextlib/iwidgets/catalog_demo/images/new.gif | Bin 0 -> 212 bytes .../tkextlib/iwidgets/catalog_demo/images/open.gif | Bin 0 -> 258 bytes .../tkextlib/iwidgets/catalog_demo/images/oval.xbm | 14 ++ .../iwidgets/catalog_demo/images/paste.gif | Bin 0 -> 376 bytes .../iwidgets/catalog_demo/images/points.xbm | 14 ++ .../tkextlib/iwidgets/catalog_demo/images/poly.gif | Bin 0 -> 141 bytes .../iwidgets/catalog_demo/images/print.gif | Bin 0 -> 263 bytes .../iwidgets/catalog_demo/images/ruler.gif | Bin 0 -> 174 bytes .../tkextlib/iwidgets/catalog_demo/images/save.gif | Bin 0 -> 270 bytes .../iwidgets/catalog_demo/images/select.gif | Bin 0 -> 124 bytes .../tkextlib/iwidgets/catalog_demo/images/text.xbm | 14 ++ ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb | 2 +- .../sample/tkextlib/iwidgets/sample/finddialog.rb | 15 ++ .../tkextlib/iwidgets/sample/labeledframe.rb | 14 ++ .../sample/tkextlib/iwidgets/sample/mainwindow.rb | 64 +++++++++ ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb | 124 +++++++++++++++++ ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb | 44 ++++++ ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb | 30 ++++ .../sample/tkextlib/iwidgets/sample/notebook2.rb | 30 ++++ .../sample/tkextlib/iwidgets/sample/optionmenu.rb | 14 ++ .../sample/tkextlib/iwidgets/sample/panedwindow.rb | 22 +++ .../tkextlib/iwidgets/sample/panedwindow2.rb | 22 +++ .../tkextlib/iwidgets/sample/promptdialog.rb | 17 +++ .../sample/tkextlib/iwidgets/sample/pushbutton.rb | 9 ++ .../tkextlib/iwidgets/sample/scrolledcanvas.rb | 13 ++ .../tkextlib/iwidgets/sample/scrolledframe.rb | 18 +++ .../tkextlib/iwidgets/sample/scrolledhtml.rb | 15 ++ .../tkextlib/iwidgets/sample/scrolledlistbox.rb | 22 +++ .../tkextlib/iwidgets/sample/scrolledtext.rb | 11 ++ .../tkextlib/iwidgets/sample/selectionbox.rb | 19 +++ .../tkextlib/iwidgets/sample/selectiondialog.rb | 12 ++ ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb | 7 + ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb | 10 ++ ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb | 33 +++++ ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb | 7 + .../sample/tkextlib/iwidgets/sample/tabnotebook.rb | 26 ++++ .../tkextlib/iwidgets/sample/tabnotebook2.rb | 30 ++++ ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb | 34 +++++ ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb | 152 +++++++++++++++++++++ ext/tk/sample/tkextlib/tkHTML/COPYRIGHT.orig | 12 ++ ext/tk/sample/tkextlib/tktable/LICENSE.orig | 52 +++++++ ext/tk/sample/tkextlib/tktable/basic.rb | 60 ++++++++ ext/tk/sample/tkextlib/tktable/buttons.rb | 76 +++++++++++ ext/tk/sample/tkextlib/tktable/command.rb | 89 ++++++++++++ ext/tk/sample/tkextlib/tktable/debug.rb | 101 ++++++++++++++ ext/tk/sample/tkextlib/tktable/dynarows.rb | 99 ++++++++++++++ ext/tk/sample/tkextlib/tktable/maxsize.rb | 67 +++++++++ ext/tk/sample/tkextlib/tktable/tcllogo.gif | Bin 0 -> 2341 bytes ext/tk/sample/tkextlib/tktable/valid.rb | 88 ++++++++++++ ext/tk/sample/tkextlib/vu/LICENSE.orig | 2 +- 69 files changed, 1593 insertions(+), 5 deletions(-) create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/LICENSE.orig create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif create mode 100644 ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb create mode 100644 ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb create mode 100644 ext/tk/sample/tkextlib/tkHTML/COPYRIGHT.orig create mode 100644 ext/tk/sample/tkextlib/tktable/LICENSE.orig create mode 100644 ext/tk/sample/tkextlib/tktable/basic.rb create mode 100644 ext/tk/sample/tkextlib/tktable/buttons.rb create mode 100644 ext/tk/sample/tkextlib/tktable/command.rb create mode 100644 ext/tk/sample/tkextlib/tktable/debug.rb create mode 100644 ext/tk/sample/tkextlib/tktable/dynarows.rb create mode 100644 ext/tk/sample/tkextlib/tktable/maxsize.rb create mode 100755 ext/tk/sample/tkextlib/tktable/tcllogo.gif create mode 100644 ext/tk/sample/tkextlib/tktable/valid.rb (limited to 'ext/tk/sample/tkextlib') diff --git a/ext/tk/sample/tkextlib/ICONS/LICENSE.orig b/ext/tk/sample/tkextlib/ICONS/LICENSE.orig index 1a03ced2d8..71e359559a 100644 --- a/ext/tk/sample/tkextlib/ICONS/LICENSE.orig +++ b/ext/tk/sample/tkextlib/ICONS/LICENSE.orig @@ -2,7 +2,7 @@ ######################################################################### ### The following text is the original file of the Tcl/Tk extension. ### ### Icon data files ( those are 'tkIcons', 'tkIcons-sample.kde', and ### - ### 'tkIcons.kde' ) are refered from the source archive of ICONS ### + ### 'tkIcons.kde' ) are quoted from the source archive of ICONS ### ### extension. As the following document describes, those icon images ### ### are not applied the license. ### ######################################################################### diff --git a/ext/tk/sample/tkextlib/ICONS/viewIcons.rb b/ext/tk/sample/tkextlib/ICONS/viewIcons.rb index 84b3d0f63c..fa8741f415 100644 --- a/ext/tk/sample/tkextlib/ICONS/viewIcons.rb +++ b/ext/tk/sample/tkextlib/ICONS/viewIcons.rb @@ -228,7 +228,7 @@ class ViewIcons name = @icon_name[item] data_width = 60 - cmd = "#{name} = TkPhotoImage.new(:date=><<'EOD')\n" + cmd = "#{name} = TkPhotoImage.new(:data=><<'EOD')\n" icon_data = Tk::ICONS.query(name, :file=>@library.value, :items=>'d')[0][0] diff --git a/ext/tk/sample/tkextlib/bwidget/LICENSE.orig b/ext/tk/sample/tkextlib/bwidget/LICENSE.orig index 4238e43877..0c4c16fe47 100644 --- a/ext/tk/sample/tkextlib/bwidget/LICENSE.orig +++ b/ext/tk/sample/tkextlib/bwidget/LICENSE.orig @@ -5,7 +5,7 @@ ### Original Tcl source files are not include in this directry, ### ### because of all of them are rewrited to Ruby files. ### ### However, the bitmap data files ('bwidgtet.xbm' and 'x1.xbm') ### - ### included in this directory are referd from BWidget source ### + ### included in this directory are quoted from BWidget source ### ### archive. So, those bitmaps are under the following license. ### ###################################################################### diff --git a/ext/tk/sample/tkextlib/bwidget/basic.rb b/ext/tk/sample/tkextlib/bwidget/basic.rb index 09a29b99a5..f622c142e4 100644 --- a/ext/tk/sample/tkextlib/bwidget/basic.rb +++ b/ext/tk/sample/tkextlib/bwidget/basic.rb @@ -1,6 +1,9 @@ # # basic demo --- called from demo.rb # +unless Object.const_defined?('DemoVar') + fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " +end module DemoBasic @@var = TkVariable.new_hash diff --git a/ext/tk/sample/tkextlib/bwidget/dnd.rb b/ext/tk/sample/tkextlib/bwidget/dnd.rb index 9938b4b099..fd6cc40dda 100644 --- a/ext/tk/sample/tkextlib/bwidget/dnd.rb +++ b/ext/tk/sample/tkextlib/bwidget/dnd.rb @@ -1,6 +1,9 @@ # # dnd demo --- called from demo.rb # +unless Object.const_defined?('DemoVar') + fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " +end module DemoDnD def self.create(nb) diff --git a/ext/tk/sample/tkextlib/bwidget/manager.rb b/ext/tk/sample/tkextlib/bwidget/manager.rb index 2935a26513..65bbe0f9e6 100644 --- a/ext/tk/sample/tkextlib/bwidget/manager.rb +++ b/ext/tk/sample/tkextlib/bwidget/manager.rb @@ -1,6 +1,9 @@ # # manager demo --- called from demo.rb # +unless Object.const_defined?('DemoVar') + fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " +end module DemoManager @@progress = TkVariable.new(false) diff --git a/ext/tk/sample/tkextlib/bwidget/select.rb b/ext/tk/sample/tkextlib/bwidget/select.rb index e25ab5c354..a04d8da482 100644 --- a/ext/tk/sample/tkextlib/bwidget/select.rb +++ b/ext/tk/sample/tkextlib/bwidget/select.rb @@ -1,6 +1,9 @@ # # select demo --- called from demo.rb # +unless Object.const_defined?('DemoVar') + fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " +end module DemoSelect @@var = TkVariable.new_hash diff --git a/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb b/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb index 7589249516..1ed84e21aa 100644 --- a/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb +++ b/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb @@ -1,6 +1,9 @@ # # templdlg demo --- called from demo.rb # +unless Object.const_defined?('DemoVar') + fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " +end module DemoDialog @@tmpl = TkVariable.new_hash diff --git a/ext/tk/sample/tkextlib/bwidget/tree.rb b/ext/tk/sample/tkextlib/bwidget/tree.rb index 0d9fc38050..9bfa4f3ccf 100644 --- a/ext/tk/sample/tkextlib/bwidget/tree.rb +++ b/ext/tk/sample/tkextlib/bwidget/tree.rb @@ -1,6 +1,9 @@ # # templdlg demo --- called from demo.rb # +unless Object.const_defined?('DemoVar') + fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. " +end module DemoTree @@count = 0 diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/LICENSE.orig b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/LICENSE.orig new file mode 100644 index 0000000000..22f787609d --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/LICENSE.orig @@ -0,0 +1,42 @@ + + ####################################################################### + ### The following text is the original 'license.terms' of iwidges ### + ### extension. ### + ### Original Tcl source files are not include in this directry, ### + ### because of all of them are rewrited to Ruby files. ### + ### However, the image data files in the 'images' directory are ### + ### quoted from iwidgets source archive. ### + ####################################################################### + + +This software is copyrighted by DSC Technologies and private individual +contributors. The copyright holder is specifically listed in the header +of each file. The following terms apply to all files associated with the +software unless explicitly disclaimed in individual files by private +contributors. + +Copyright 1997 DSC Technologies Corporation + +Permission to use, copy, modify, distribute and license this software and +its documentation for any purpose, and without fee or written agreement +with DSC, is hereby granted, provided that the above copyright notice +appears in all copies and that both the copyright notice and warranty +disclaimer below appear in supporting documentation, and that the names of +DSC Technologies Corporation or DSC Communications Corporation not be used +in advertising or publicity pertaining to the software without specific, +written prior permission. + +DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-INFRINGEMENT. +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND +DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, +ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL DSC BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +RESTRICTED RIGHTS: Use, duplication or disclosure by the government +is subject to the restrictions as set forth in subparagraph (c) (1) (ii) +of the Rights in Technical Data and Computer Software Clause as DFARS +252.227-7013 and FAR 52.227-19. diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm new file mode 100644 index 0000000000..7498e15de2 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm @@ -0,0 +1,14 @@ +#define Tool_32_box_width 32 +#define Tool_32_box_height 32 +static unsigned char Tool_32_box_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x20, 0x00, 0x00, 0x08, + 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, + 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, + 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, + 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, + 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, + 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif new file mode 100644 index 0000000000..f91b9e9d1e Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif new file mode 100644 index 0000000000..7319f1dcb0 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif new file mode 100644 index 0000000000..4258b17591 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif new file mode 100644 index 0000000000..e462be033f Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif new file mode 100644 index 0000000000..dddcb8044b Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif new file mode 100644 index 0000000000..bc8f18c00d Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm new file mode 100644 index 0000000000..4622ae978b --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm @@ -0,0 +1,14 @@ +#define lineOp_width 32 +#define lineOp_height 32 +static unsigned char lineOp_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, + 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, + 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, + 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, + 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3c, 0x00, + 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01, + 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f, + 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif new file mode 100644 index 0000000000..4a5be66e76 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif new file mode 100644 index 0000000000..9c68ad35f5 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif new file mode 100644 index 0000000000..bed862c8c4 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm new file mode 100644 index 0000000000..856bd43785 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm @@ -0,0 +1,14 @@ +#define ovalOp_width 32 +#define ovalOp_height 32 +static unsigned char ovalOp_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, + 0x00, 0x1c, 0x70, 0x00, 0x00, 0x03, 0x80, 0x01, 0x80, 0x00, 0x00, 0x02, + 0x40, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20, + 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x10, + 0x10, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04, + 0x80, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, 0x01, 0x00, 0x1c, 0x70, 0x00, + 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif new file mode 100644 index 0000000000..9974f23bf5 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm new file mode 100644 index 0000000000..c50aa4c5f3 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm @@ -0,0 +1,14 @@ +#define dotPencilOp_width 32 +#define dotPencilOp_height 32 +static unsigned char dotPencilOp_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x12, 0x00, + 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x80, 0x04, 0x00, + 0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, + 0x00, 0x20, 0x01, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, + 0x00, 0x90, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, + 0x00, 0x24, 0x00, 0x18, 0x00, 0x24, 0x00, 0x18, 0x00, 0x12, 0x00, 0x00, + 0x00, 0x12, 0x00, 0x30, 0x00, 0x0e, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00, + 0x00, 0x06, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x30, 0xa0, 0x01, + 0x00, 0x60, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif new file mode 100644 index 0000000000..2b595bb9b7 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif new file mode 100644 index 0000000000..d321f17457 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif new file mode 100644 index 0000000000..00d26febf6 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif new file mode 100644 index 0000000000..d1ceb1a5c4 Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif new file mode 100644 index 0000000000..f885c9ca5f Binary files /dev/null and b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif differ diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm new file mode 100644 index 0000000000..ffb0686303 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm @@ -0,0 +1,14 @@ +#define font_edit_width 32 +#define font_edit_height 32 +static unsigned char font_edit_bits[] = { + 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c, + 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x80, 0x7b, + 0x00, 0x00, 0x80, 0x7e, 0x00, 0x00, 0xc0, 0xfd, 0x00, 0x00, 0x60, 0xfb, + 0x00, 0x00, 0xb0, 0xf7, 0x00, 0x00, 0xd0, 0xef, 0x00, 0x00, 0xf8, 0xdf, + 0x00, 0x00, 0xd4, 0x7f, 0x00, 0x00, 0xaa, 0x1f, 0x00, 0x00, 0x15, 0x0f, + 0x00, 0x80, 0x82, 0x06, 0x03, 0x40, 0x01, 0x01, 0x07, 0xa0, 0x80, 0x00, + 0x0f, 0x10, 0x40, 0x00, 0x1f, 0x08, 0x20, 0x00, 0x3b, 0xe4, 0x1f, 0x00, + 0x73, 0x1a, 0x00, 0x00, 0xe3, 0x07, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x00, + 0xe3, 0x03, 0x00, 0x00, 0x7b, 0x07, 0x00, 0x00, 0x1f, 0x06, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb b/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb index c39ebd9d22..7b87a029ed 100644 --- a/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb +++ b/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb @@ -4,7 +4,7 @@ require 'tkextlib/iwidgets' Tk::Iwidgets::Feedback.new(:labeltext=>'Status', :steps=>20){|fb| pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) - TkTimer.new(500, 20, proc{fb.step}).start(5000) + TkTimer.new(500, 20, proc{fb.step}).start(2500) } Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb new file mode 100644 index 0000000000..110efb9b96 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +mainloop = Thread.new{Tk.mainloop} + +st = Tk::Iwidgets::Scrolledtext.new.pack +st.insert('end', "Now is the time for all good men\n") +st.insert('end', "to come to the aid of their country") + +fd = Tk::Iwidgets::Finddialog.new(:textwidget=>st) +fd.center(st) +fd.activate + +mainloop.join diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb b/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb new file mode 100644 index 0000000000..4e2e21e727 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +lf = Tk::Iwidgets::Labeledframe.new(:labeltext=>'Entry Frame', :labelpos=>:n) +lf.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10) + +cs = lf.child_site + +Tk::Iwidgets::Entryfield.new(cs, :labeltext=>'Name:').pack(:side=>:top, :fill=>:x) +Tk::Iwidgets::Spinint.new(cs, :labeltext=>'Number:').pack(:side=>:top, :fill=>:x) +Tk::Iwidgets::Pushbutton.new(cs, :text=>'Details:').pack(:side=>:top, :fill=>:x) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb b/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb new file mode 100644 index 0000000000..85b28b45e7 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb @@ -0,0 +1,64 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +mw = Tk::Iwidgets::Mainwindow.new + +mw.menubar.add(:menubutton, 'file', :text=>'File', :underline=>0, + :padx=>8, :pady=>2, :menu=>[ + [:options, {:tearoff=>false}], + + [:command, 'new', { + :label=>'New', :underline=>0, + :helpstr=>'Create a new file' + } + ], + + [:command, 'open', { + :label=>'Open ...', :underline=>0, + :helpstr=>'Open an existing file' + } + ], + + [:command, 'save', { + :label=>'Save', :underline=>0, + :helpstr=>'Save the current file' + } + ], + + [:command, 'saveas', { + :label=>'Save As', :underline=>5, + :helpstr=>'Save the file as a different name' + } + ], + + [:command, 'print', { + :label=>'Print', :underline=>0, + :helpstr=>'Print the file' + } + ], + + [:separator, 'sep1'], + + [:command, 'close', { + :label=>'Close', :underline=>0, + :helpstr=>'Close the file' + } + ], + + [:separator, 'sep2'], + + [:command, 'exit', { + :label=>'Exit', :underline=>1, + :helpstr=>'Exit this application' + } + ], + + nil + ]) + +Tk::Iwidgets::Scrolledtext.new(mw.child_site).pack(:fill=>:both, :expand=>true) + +mw.activate + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb new file mode 100644 index 0000000000..c61071470f --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb @@ -0,0 +1,124 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +helpvar = TkVariable.new +viewmode = TkVariable.new + +menu_spec = [ + [:menubutton, 'file', { + :text=>'File', :menu=>[ + [:options, {:tearoff=>false}], + + [:command, 'new', { + :label=>'New', :helpstr=>'Open new document', + :command=>proc{puts 'NEW'} + } + ], + + [:command, 'close', { + :label=>'Close', :helpstr=>'Close current document', + :command=>proc{puts 'CLOSE'} + } + ], + + [:separator, 'sep1'], + + [:command, 'exit', { + :label=>'Exit', :helpstr=>'Exit application', + :command=>proc{exit} + } + ] + ] + } + ], + + [:menubutton, 'edit', { + :text=>'Edit', :menu=>[ + [:options, {:tearoff=>false}], + + [:command, 'undo', { + :label=>'Undo', :underline=>0, + :helpstr=>'Undo last command', + :command=>proc{puts 'UNDO'} + } + ], + + [:separator, 'sep2'], + + [:command, 'cut', { + :label=>'Cut', :underline=>1, + :helpstr=>'Cut selection to clipboard', + :command=>proc{puts 'CUT'} + } + ], + + [:command, 'copy', { + :label=>'Copy', :underline=>1, + :helpstr=>'Copy selection to clipboard', + :command=>proc{puts 'COPY'} + } + ], + + [:command, 'paste', { + :label=>'Paste', :underline=>0, + :helpstr=>'Paste clipboard contents', + :command=>proc{puts 'PASTE'} + } + ] + ] + } + ], + + [:menubutton, 'options', { + :text=>'Options', :menu=>[ + [:options, {:tearoff=>false, :selectcolor=>'blue'}], + + [:radiobutton, 'byName', { + :variable=>viewmode, :value=>'NAME', + :label=>'by Name', :helpstr=>'View files by name order', + :command=>proc{puts 'NAME'} + } + ], + + [:radiobutton, 'byDate', { + :variable=>viewmode, :value=>'DATE', + :label=>'by Date', :helpstr=>'View files by date order', + :command=>proc{puts 'DATE'} + } + ], + + [:cascade, 'prefs', { + :label=>'Preferences', :menu=>[ + [:command, 'colors', { + :label=>'Colors...', :helpstr=>'Change text colors', + :command=>proc{puts 'COLORS'} + } + ], + + [:command, 'fonts', { + :label=>'Fonts...', :helpstr=>'Change text font', + :command=>proc{puts 'COLORS'} + } + ] + ] + } + ] + ] + } + ] +] + +#mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar, +# :menubuttons=>menu_spec) +mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar) +mb.configure(:menubuttons=>menu_spec) + +fr = TkFrame.new(:width=>300, :height=>300) +ef = TkEntry.new(:textvariable=>helpvar) + +mb.pack(:anchor=>:nw, :fill=>:x, :expand=>true) +fr.pack(:fill=>:both, :expand=>true) +ef.pack(:anchor=>:sw, :fill=>:x, :expand=>true) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb new file mode 100644 index 0000000000..eec4928afb --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +helpvar = TkVariable.new +viewmode = TkVariable.new + +mb = Tk::Iwidgets::Menubar.new +mb.menubuttons = [ + [:menubutton, 'file', { + :text=>'File', :menu=>[ + [:command, 'new', {:label=>'New'}], + [:command, 'close', {:label=>'Close'}], + [:separator, 'sep1'], + [:command, 'quit', {:label=>'Quit'}] + ] + } + ], + [:menubutton, 'edit', {:text=>'Edit'}] +] + +mb.add(:command, '.edit.undo', :label=>'Undo', :underline=>0) +mb.add(:separator, '.edit.sep2') +mb.add(:command, '.edit.cut', :label=>'Cut', :underline=>1) +mb.add(:command, '.edit.copy', :label=>'Copy', :underline=>1) +mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0) + +mb.add(:menubutton, '.options', :text=>'Options', :menu=>[ + [:radiobutton, 'byName', { + :variable=>viewmode, :value=>'NAME', :label=>'by Name'} + ], + [:radiobutton, 'byDate', { + :variable=>viewmode, :value=>'DATE', :label=>'by Date'} + ] + ]) + +mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[ + [:command, 'colors', {:label=>'Colors...'}], + [:command, 'fonts', {:label=>'Fonts...'}] + ]) + +mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb b/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb new file mode 100644 index 0000000000..77f1c1dc63 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +# Create the tabnotebook widget and pack it. +nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100) +nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true, + :side=>:left, :padx=>10, :pady=>10) + +# Add two pages to the tabnotebook, +# labelled "Page One" and "Page Two" +nb.add(:label=>'Page One') +nb.add(:label=>'Page Two') + +# Get the child site frames of these two pages. +page1CS = nb.child_site(0) +page2CS = nb.child_site('Page Two') + +# Create buttons on each page of the tabnotebook. +TkButton.new(page1CS, :text=>'Button One').pack +TkButton.new(page2CS, :text=>'Button Two').pack + +# Select the first page of the tabnotebook. +nb.select(0) + +# Create the scrollbar and associate teh scrollbar +# and the notebook together, then pack the scrollbar +nb.scrollbar(TkScrollbar.new).pack(:fill=>:y, :expand=>true, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb new file mode 100644 index 0000000000..e14e1207a5 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +# Create the tabnotebook widget and pack it. +nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100) +nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true, + :side=>:top, :padx=>10, :pady=>0) + +# Add two pages to the tabnotebook, +# labelled "Page One" and "Page Two" +nb.add(:label=>'Page One') +nb.add(:label=>'Page Two') + +# Get the child site frames of these two pages. +page1CS = nb.child_site(0) +page2CS = nb.child_site('Page Two') + +# Create buttons on each page of the tabnotebook. +TkButton.new(page1CS, :text=>'Button One').pack +TkButton.new(page2CS, :text=>'Button Two').pack + +# Select the first page of the tabnotebook. +nb.select(0) + +# Create the scrollbar and associate teh scrollbar +# and the notebook together, then pack the scrollbar +nb.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb b/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb new file mode 100644 index 0000000000..bdeafb691e --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +om = Tk::Iwidgets::Optionmenu.new(:labelmargin=>5, :labelpos=>:w, + :labeltext=>"Operating System :") + +om.insert('end', 'Unix', 'VMS', 'Linux', 'OS/2', 'Windows NT', 'DOS') +om.sort_ascending +om.select('Linux') + +om.pack(:padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb new file mode 100644 index 0000000000..902b2c4bcb --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300) + +pw.add('top') +pw.add('middle', :margin=>10) +pw.add('bottom', :margin=>10, :minimum=>10) + +pw.pack(:fill=>:both, :expand=>true) + +pw.child_site_list.each{|pane| + TkButton.new(pane, :text=>pane.path, :relief=>:raised, + :borderwidth=>2).pack(:fill=>:both, :expand=>true) +} + +pw.fraction(50,30,20) +pw.paneconfigure(0, :minimum=>20) +pw.paneconfigure('bottom', :margin=>15) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb new file mode 100644 index 0000000000..8928393a8b --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300) + +top = pw.add +middle = pw.add(:margin=>10) +bottom = pw.add(:margin=>10, :minimum=>10) + +pw.pack(:fill=>:both, :expand=>true) + +pw.child_site_list.each{|pane| + TkButton.new(pane, :text=>pane.path, :relief=>:raised, + :borderwidth=>2).pack(:fill=>:both, :expand=>true) +} + +pw.fraction(50,30,20) +pw.paneconfigure(0, :minimum=>20) # 0 == pw.index(top) +pw.paneconfigure(bottom, :margin=>15) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb new file mode 100644 index 0000000000..7dbecc6dc0 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +mainloop = Thread.new{Tk.mainloop} + +TkOption.add('*textBackground', 'white') + +pd = Tk::Iwidgets::Promptdialog.new(:modality=>:global, :title=>'Password', + :labeltext=>'Password:', :show=>'*') +pd.hide('Apply') + +if TkComm.bool(pd.activate) + puts "Password entered: #{pd.get}" +else + puts "Password prompt cancelled" +end diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb b/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb new file mode 100644 index 0000000000..b1f4d7d118 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +Tk::Iwidgets::Pushbutton.new(:text=>'Hello', + :command=>proc{puts 'Hello World'}, + :defaultring=>true).pack(:padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb new file mode 100644 index 0000000000..92c94b96bb --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +sc = Tk::Iwidgets::Scrolledcanvas.new + +sc.create(TkcRectangle, 100, 100, 400, 400, :fill=>'red') +TkcRectangle.new(sc, 300, 300, 600, 600, :fill=>'green') +TkcRectangle.new(sc, [[200, 200], [500, 500]], :fill=>'blue') + +sc.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb new file mode 100644 index 0000000000..c12b664482 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +sf = Tk::Iwidgets::Scrolledframe.new(:width=>150, :height=>180, + :labeltext=>'scrolledframe') +cs = sf.child_site + +TkButton.new(cs, :text=>'Hello').pack(:pady=>10) +TkButton.new(cs, :text=>'World').pack(:pady=>10) +TkButton.new(cs, :text=>'This is a test').pack(:pady=>10) +TkButton.new(cs, :text=>'This is a really big button').pack(:pady=>10) +TkButton.new(cs, :text=>'This is another really big button').pack(:pady=>10) +TkButton.new(cs, :text=>'This is the last really big button').pack(:pady=>10) + +sf.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb new file mode 100644 index 0000000000..6b0827ec89 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +TkOption.add('*textBackground', 'white') + +sh = Tk::Iwidgets::Scrolledhtml.new(:fontname=>'helvetica', + :linkcommand=>proc{|href| + sh.import_link(href) + }) +sh.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) + +sh.import(Tk.getOpenFile(:title=>'select HTML document')) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb new file mode 100644 index 0000000000..98f932d058 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +TkOption.add('*textBackground', 'white') + +slb = Tk::Iwidgets::Scrolledlistbox.new(:selectmode=>:single, + :vscrollmode=>:static, + :hscrollmode=>:dynamic, + :labeltext=>'List', + :selectioncommand=>proc{ + puts(slb.get_curselection) + }, + :dblclickcommand=>proc{ + puts('Double Click') + puts(slb.get_curselection) + }) +slb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) + +slb.insert('end', *['Hello', 'Out There', 'World']) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb new file mode 100644 index 0000000000..59a96fb9f6 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +st = Tk::Iwidgets::Scrolledtext.new(:hscrollmode=>:dynamic, :wrap=>:none, + :labeltext=>'Password File') +st.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) + +st.import('/etc/passwd') + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb new file mode 100644 index 0000000000..d19970fac9 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb @@ -0,0 +1,19 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +TkOption.add('*textBackground', 'white') + +sb = Tk::Iwidgets::Selectionbox.new.pack(:padx=>10, :pady=>10, + :fill=>:both, :expand=>true) + +sb.insert_items('end', *['Hello', 'Out There', 'World']) + +TkLabel.new(sb.child_site, + :text=>'Child Site is Here').pack(:fill=>:x, :padx=>10, :pady=>10) + +sb.insert_items(2, 'Cruel Cruel') + +sb.selection_set(1) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb new file mode 100644 index 0000000000..4fbb2aa378 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +mainloop = Thread.new{Tk.mainloop} + +TkButton.new(:text=>'QUIT', + :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10) + +Tk::Iwidgets::Selectiondialog.new.activate + +mainloop.join diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb new file mode 100644 index 0000000000..17197a66b7 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +Tk::Iwidgets::Spindate.new.pack(:padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb new file mode 100644 index 0000000000..4064081740 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +TkOption.add('*textBackground', 'white') + +Tk::Iwidgets::Spinint.new(:labeltext=>'Temperature', :labelpos=>:w, :width=>5, + :fixed=>true, :range=>[32, 212]).pack(:pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb new file mode 100644 index 0000000000..44e8ec3034 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +class Spinner_demo < TkWindow + Months = %w(January February March April May June July August September October November December) + + def block_input(c) + false + end + + def spin_month(step) + index = Months.index(@spinner.get) + step + index = 11 if index < 0 + index = 0 if index > 11 + + @spinner.value = Months[index] + end + + def initialize(parent=nil) + @spinner = Tk::Iwidgets::Spinner.new(parent, :labeltext=>'Month : ', + :width=>10, :fixed=>10, + :validate=>proc{|c| block_input}, + :decrement=>proc{spin_month -1}, + :increment=>proc{spin_month 1}) + @path = @spinner + @spinner.insert(0, Months[0]) + end +end + +Spinner_demo.new.pack(:padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb new file mode 100644 index 0000000000..2c13884b94 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +Tk::Iwidgets::Spintime.new.pack(:padx=>10, :pady=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb new file mode 100644 index 0000000000..5a9897845f --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +# Create the tabnotebook widget and pack it. +tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) +tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, + :side=>:left, :padx=>10, :pady=>10) + +# Add two pages to the tabnotebook, +# labelled "Page One" and "Page Two" +tn.add(:label=>'Page One') +tn.add(:label=>'Page Two') + +# Get the child site frames of these two pages. +page1CS = tn.child_site(0) +page2CS = tn.child_site('Page Two') + +# Create buttons on each page of the tabnotebook. +TkButton.new(page1CS, :text=>'Button One').pack +TkButton.new(page2CS, :text=>'Button Two').pack + +# Select the first page of the tabnotebook. +tn.select(0) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb new file mode 100644 index 0000000000..c08603f899 --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +# Create the tabnotebook widget and pack it. +tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100) +tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true, + :side=>:top, :padx=>10, :pady=>0) + +# Add two pages to the tabnotebook, +# labelled "Page One" and "Page Two" +tn.add(:label=>'Page One') +tn.add(:label=>'Page Two') + +# Get the child site frames of these two pages. +page1CS = tn.child_site(0) +page2CS = tn.child_site('Page Two') + +# Create buttons on each page of the tabnotebook. +TkButton.new(page1CS, :text=>'Button One').pack +TkButton.new(page2CS, :text=>'Button Two').pack + +# Select the first page of the tabnotebook. +tn.select(0) + +# Create the scrollbar +# and the notebook together, then pack the scrollbar +tn.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb new file mode 100644 index 0000000000..90be46b40b --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +# Create a listbox with two items (one and two) +l = TkListbox.new(:selectmode=>:single, :exportselection=>false).pack +l.insert('end', 'one') +l.insert('end', 'two') +l.selection_set(0) + +# Define a proc that knows how to select an item +# from a list given an index from the tabset -command callback. +selectItem = proc{|item| + l.selection_clear(l.curselection) + l.selection_set(item) + l.see(item) +} + +# Create a tabset, set its -command to call selectItem +# Add two labels to the tabset (one and two). +ts = Tk::Iwidgets::Tabset.new(:command=>selectItem) +ts.add(:label=>1) +ts.add(:label=>2) +ts.select(0) +ts.pack(:fill=>:x, :expand=>true) + +# Define a proc that knows how to select a tab +# given a y pixel coordinate from the list.. +selectTab = proc{|y| ts.select(l.nearest(y)) } + +# bind button 1 press to the selectTab procedure. +l.bind('ButtonPress-1', proc{|y| selectTab.call(y) }, '%y') + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb new file mode 100644 index 0000000000..eba52ba5db --- /dev/null +++ b/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb @@ -0,0 +1,152 @@ +#!/usr/bin/env ruby +require 'tk' +require 'tkextlib/iwidgets' + +########################################## +# icon images +editcopy22 = TkPhotoImage.new(:data=><<'EOD') + R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxa + XMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy + 7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyy + lPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbY + QIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6 + GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBsc + AY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4g + KIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATy + VoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0 + ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5 + OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2 + ZWxjb3IuY29tADs= +EOD + +editcut22 = TkPhotoImage.new(:data=><<'EOD') + R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAA + AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE + 0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkc + pkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVh + dGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAx + OTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRl + dmVsY29yLmNvbQA7 +EOD + +editpaste22 = TkPhotoImage.new(:data=><<'EOD') + R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6 + /NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS + 1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2 + tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq + 7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6 + PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz2 + 7Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTS + tNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA + LAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4F + DxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wr + LS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCN + DiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LA + QOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4 + wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4 + oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpg + weLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5 + OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5 + IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5 + OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29y + LmNvbQA7 +EOD + +editdelete22 = TkPhotoImage.new(:data=><<'EOD') + R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwK + DAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzK + xIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwC + BMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyy + nOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA + LAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMN + EqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqz + kBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0S + F+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsyg + sVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDY + CKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENy + ZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29y + IDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cu + ZGV2ZWxjb3IuY29tADs= +EOD + +text22 = TkPhotoImage.new(:data=><<'EOD') + R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRS + VCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmK + QSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bs + t9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5o + Q3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxD + b3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3 + dy5kZXZlbGNvci5jb20AOw== +EOD + +########################################## + +bmp_dir = File.join(File.dirname(File.expand_path(__FILE__)), + '../catalog_demo/images') + +########################################## + +status_var = TkVariable.new +radio_var = TkVariable.new +check_var1 = TkVariable.new +check_var2 = TkVariable.new + +tb = Tk::Iwidgets::Toolbar.new(:helpvariable=>status_var) + +########################################## + +tb.add(:button, :helpstr=>'Copy It', :image=>editcopy22, + :balloonstr=>'Copy', :command=>proc{puts 'Copy It'}) + +tb.add(:button, :helpstr=>'Cut It', :image=>editcut22, + :balloonstr=>'Cut', :command=>proc{puts 'Cut It'}) + +tb.add(:button, :helpstr=>'Paste It', :image=>editpaste22, + :balloonstr=>'Paste', :command=>proc{puts 'Paste It'}) + +tb.add(:button, :helpstr=>'Delete It', :image=>editdelete22, + :balloonstr=>'Delete', :command=>proc{puts 'Delete It'}) + +#-------------------------------- + +tb.add(:frame, :borderwidth=>1, :width=>10, :height=>10) + +#-------------------------------- + +tb.add(:radiobutton, :variable=>radio_var, :value=>'Box', + :bitmap=>"@#{bmp_dir}/box.xbm", + :helpstr=>'Radio Button #1', :balloonstr=>'Radio', + :command=>proc{puts 'Radio Button "Box"'}) + +tb.add(:radiobutton, :variable=>radio_var, :value=>'Line', + :bitmap=>"@#{bmp_dir}/line.xbm", + :helpstr=>'Radio Button #2', :balloonstr=>'Radio', + :command=>proc{puts 'Radio Button "Line"'}) + +tb.add(:radiobutton, :variable=>radio_var, :value=>'Oval', + :bitmap=>"@#{bmp_dir}/oval.xbm", + :helpstr=>'Radio Button #3', :balloonstr=>'Radio', + :command=>proc{puts 'Radio Button "Oval"'}) + +#-------------------------------- + +tb.add(:frame, :borderwidth=>1, :width=>10, :height=>10) + +#-------------------------------- + +tb.add(:checkbutton, :variable=>check_var1, :onvalue=>'yes', :offvalue=>'no', + :image=>text22, :command=>proc{puts 'Checkbutton 1'}) + +tb.add(:checkbutton, :variable=>check_var2, :onvalue=>'yes', :offvalue=>'no', + :bitmap=>"@#{bmp_dir}/points.xbm", :command=>proc{puts 'Checkbutton 2'}) + +tb.pack(:side=>:top, :anchor=>:nw) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tkHTML/COPYRIGHT.orig b/ext/tk/sample/tkextlib/tkHTML/COPYRIGHT.orig new file mode 100644 index 0000000000..2b3757bb23 --- /dev/null +++ b/ext/tk/sample/tkextlib/tkHTML/COPYRIGHT.orig @@ -0,0 +1,12 @@ + +The following text is the original 'COPYRIGHT' file of tkHTML. + +----------------------------------------------------------------------- +Most of the source code for the Tk Html widget has been place in the +public domain. You can do with it whatever you want. However, some +files have been copied from other sources and contain copyrights. +A copyright notice appears separately at the top of each source file. +----------------------------------------------------------------------- + +In this sample, HTML documents are quoted in the 'tests' directory of +tkHTML source tree. There were no copyright notice in the directory. diff --git a/ext/tk/sample/tkextlib/tktable/LICENSE.orig b/ext/tk/sample/tkextlib/tktable/LICENSE.orig new file mode 100644 index 0000000000..dd176a7ccf --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/LICENSE.orig @@ -0,0 +1,52 @@ + + ####################################################################### + ### The following text is the original 'license.txt' of tktable ### + ### extension. ### + ### Original Tcl source files are not include in this directry, ### + ### because of all of them are rewrited to Ruby files. ### + ### However, the image data file is quoted from iwidgets source ### + ### archive. ### + ####################################################################### + + + * COPYRIGHT AND LICENSE TERMS * + +(This file blatantly stolen from Tcl/Tk license and adapted - thus assume +it falls under similar license terms). + +This software is copyrighted by Jeffrey Hobbs . The +following terms apply to all files associated with the software unless +explicitly disclaimed in individual files. + +The authors hereby grant permission to use, copy, modify, distribute, and +license this software and its documentation for any purpose, provided that +existing copyright notices are retained in all copies and that this notice +is included verbatim in any distributions. No written agreement, license, +or royalty fee is required for any of the authorized uses. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT +OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, +EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS +PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO +OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +RESTRICTED RIGHTS: Use, duplication or disclosure by the U.S. government +is subject to the restrictions as set forth in subparagraph (c) (1) (ii) +of the Rights in Technical Data and Computer Software Clause as DFARS +252.227-7013 and FAR 52.227-19. + +SPECIAL NOTES: + +This software also falls under the bourbon_ware clause: + + Should you find this software useful in your daily work, you should + feel obliged to take the author out for a drink if the opportunity + presents itself. The user may feel exempt from this clause if they + are under 21 or think the author has already partaken of too many + drinks. diff --git a/ext/tk/sample/tkextlib/tktable/basic.rb b/ext/tk/sample/tkextlib/tktable/basic.rb new file mode 100644 index 0000000000..a7dfe2a789 --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/basic.rb @@ -0,0 +1,60 @@ +#!/usr/bin/env ruby +## +## basic.rb +## +## This demo shows the basic use of the table widget +## +## ( based on 'basic.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +ary = TkVariable.new_hash +rows = 8 +cols = 8 + +# fill table variable +((-(rows))..rows).each{|x| + ((-(cols))..cols).each{|y| + ary[x,y] = "r#{x},c#{y}" + } +} + +lbl = TkLabel.new(:text=>"TkTable v1 Example") + +table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, + :width=>6, :height=>6, + :titlerows=>1, :titlecols=>2, + :roworigin=>-1, :colorigin=>-2, + :rowstretchmode=>:last, :colstretchmode=>:last, + :rowtagcommand=>proc{|row| + row = Integer(row) + return 'OddRow' if row>0 && row%2 == 1 + }, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, :sparsearray=>false) + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +btn = TkButton.new(:text=>'Exit', :command=>proc{exit}) + +Tk.grid(lbl, '-', :sticky=>:ew) +Tk.grid(table, sy, :sticky=>:news) +Tk.grid(sx, :sticky=>:ew) +Tk.grid(btn, :sticky=>:ew, :columnspan=>2) + +Tk.root.grid_columnconfig(0, :weight=>1) +Tk.root.grid_rowconfig(1, :weight=>1) + +table.tag_configure('OddRow', :bg=>'orange', :fg=>'purple') +table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink') + +table.set_width([-2, 7], [-1, 7], [1, 5], [2, 8], [4, 14]) + +puts "Table is #{table.path} with array #{(table['variable'])}" + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/buttons.rb b/ext/tk/sample/tkextlib/tktable/buttons.rb new file mode 100644 index 0000000000..b6995bb54b --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/buttons.rb @@ -0,0 +1,76 @@ +#!/usr/bin/env ruby +## +## buttons.rb +## +## demonstrates the simulation of a button array +## +## ( based on 'buttons.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +# create the table +tab = TkVariable.new_hash +rows = 20 +cols = 20 + +table = Tk::TkTable.new(:rows=>rows + 1, :cols=>cols + 1, + :variable=>tab, :titlerows=>1, :titlecols=>1, + :roworigin=>-1, :colorigin=>-1, + :colwidth=>4, :width=>8, :height=>8, + :cursor=>'top_left_arrow', :borderwidth=>2, + :flashmode=>false, :state=>:disabled) + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +Tk.grid(table, sy, :sticky=>:news) +Tk.grid(sx, :sticky=>:ew) + +Tk.root.grid_columnconfig(0, :weight=>1) +Tk.root.grid_rowconfig(0, :weight=>1) + +# set up tags for the various states of the buttons +table.tag_configure('OFF', :bg=>'red', :relief=>:raised) +table.tag_configure('ON', :bg=>'green', :relief=>:sunken) +table.tag_configure('sel', :bg=>'gray75', :relief=>:flat) + +# clean up if mouse leaves the widget +table.bind('Leave', proc{|w| w.selection_clear_all}, '%W') + +# highlight the cell under the mouse +table.bind('Motion', proc{|w, x, y| + Tk.callback_break if w.selection_include?(TkComm._at(x,y)) + w.selection_clear_all + w.selection_set(TkComm._at(x,y)) + Tk.callback_break + ## "break" prevents the call to tkTableCheckBorder + }, '%W %x %y') + +# mousebutton 1 toggles the value of the cell +# use of "selection includes" would work here +table.bind('1', proc{|w, x, y| + #rc = w.curselection[0] + rc = w.index(TkComm._at(x,y)) + if tab[rc] == 'ON' + tab[rc] = 'OFF' + w.tag_cell('OFF', rc) + else + tab[rc] = 'ON' + w.tag_cell('ON', rc) + end}, '%W %x %y') + + +# inititialize the array, titles, and celltags +0.step(rows){|i| + tab[i,-1] = i + 0.step(cols){|j| + if i == 0 + tab[-1,j] = j + end + tab[i,j] = "OFF" + table.tag_cell('OFF', "#{i},#{j}") + } +} + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/command.rb b/ext/tk/sample/tkextlib/tktable/command.rb new file mode 100644 index 0000000000..950bc0ccb1 --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/command.rb @@ -0,0 +1,89 @@ +#!/usr/bin/env ruby +## +## command.rb +## +## This demo shows the use of the table widget's -command options +## +## ( based on 'command.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +# create the table +data = TkVariable.new_hash +rows = 10 +cols = 10 + +# fill table variable +((-(rows))..rows).each{|x| + ((-(cols))..cols).each{|y| + data[x,y] = "#{x} x #{y}" + } +} + +lbl = TkLabel.new(:text=>"TkTable :command Example") +cur_var = TkVariable.new +current = TkLabel.new(:textvariable=>cur_var, :width=>5) +ent_var = TkVariable.new +entry = TkEntry.new(:textvariable=>ent_var) + +table = Tk::TkTable.new(:rows=>rows, :cols=>cols, + :command=>[proc{|mode, cell, val| + if (mode == :w) + data[cell] = val + else + begin + data[cell] # exist + rescue + '' # not exist + end + end + }, '%i %C %s'], + :width=>6, :height=>6, + :titlerows=>1, :titlecols=>1, + :roworigin=>-1, :colorigin=>-1, + :rowstretchmode=>:last, :colstretchmode=>:last, + :rowtagcommand=>proc{|row| + row = Integer(row) + return 'OddRow' if row>0 && row%2 == 1 + }, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, :flashmode=>true, + :rowstretch=>:unset, :colstretch=>:unset, + :browsecommand=>[proc{|w, s| + cur_var.value = s + ent_var.value = w.get(s) + }, '%W %S'], + :validate=>true, + :validatecommand=>proc{|e| + ent_var.value = e.new_value; true + }) +=begin + :validatecommand=>[ + proc{|s| + ent_var.value = s; true + }, '%S']) +=end + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +entry.bind('Return', proc{|w| table.curvalue = w.value}, '%W') + +Tk.grid(lbl, '-', '-', :sticky=>:ew) +Tk.grid(current, entry, '-', :sticky=>:ew) +Tk.grid(table, '-', sy, :sticky=>:news) +Tk.grid(sx, '-', :sticky=>:ew) + +Tk.root.grid_columnconfig(1, :weight=>1) +Tk.root.grid_rowconfig(2, :weight=>1) + +table.tag_configure('OddRow', :bg=>'orange', :fg=>'purple') +table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink') + +puts "Table is #{table.path}" + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/debug.rb b/ext/tk/sample/tkextlib/tktable/debug.rb new file mode 100644 index 0000000000..30508acea6 --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/debug.rb @@ -0,0 +1,101 @@ +#!/usr/bin/env ruby +## +## debug.rb +## +## This demo uses most features of the table widget +## +## ( based on 'debug.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +# create the table +ary = TkVariable.new_hash +rows = 25 +cols = 20 + +# fill table variable +((-(rows))..rows).each{|x| + ((-(cols))..cols).each{|y| + ary[x,y] = "r#{x},c#{y}" + } +} + +lbl = TkLabel.new(:text=>"TkTable v2 Example") + +table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, + :width=>6, :height=>6, + :titlerows=>1, :titlecols=>2, + :roworigin=>-5, :colorigin=>-2, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, :flashmode=>true, + :rowstretch=>:unset, :colstretch=>:unset, + :selecttitles=>false, :drawmode=>:single) + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +btn = TkButton.new(:text=>'Exit', :command=>proc{exit}) + +Tk.grid(lbl, '-', :sticky=>:ew) +Tk.grid(table, sy, :sticky=>:news) +Tk.grid(sx, :sticky=>:ew) +Tk.grid(btn, :sticky=>:ew, :columnspan=>2) + +Tk.root.grid_columnconfig(0, :weight=>1) +Tk.root.grid_rowconfig(1, :weight=>1) + +table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink') +table.tag_configure('title', :bg=>'red', :fg=>'green', :relief=>:sunken) +table.tag_configure('dis', :state=>:disabled) + +first = table[:colorigin] +%w(n s e w nw ne sw se c).each_with_index{|anchor, idx| + table.tag_configure(anchor, :anchor=>anchor) + table.tag_row(anchor, idx) + table.set([idx,first], anchor) +} +courier = TkFont.new(:family=>'Courier', :size=>10) +table.tag_configure('s', :font=>courier, :justify=>:center) + +logo = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), 'tcllogo.gif')) +table.tag_configure('logo', :image=>logo, :showtext=>true) +table.tag_cell('logo', [1,2], [2,3], [4,1]) +table.tag_cell('dis', [2,1], [1,-1], [3,0]) +table.set_width([-2,8], [-1,9], [0, 12], [4, 14]) + +table.set([1,1], "multi-line\ntext\nmight be\ninteresting", + [3,2], "more\nmulti-line\nplaying\n", + [2,2], "null\0byte") + +# This is in the row span +l = TkLabel.new(table, :text=>'Window s', :bg=>'yellow') +table.window_configure([6,0], :sticky=>:s, :window=>l) + +# This is in the row titles +l = TkLabel.new(table, :text=>'Window ne', :bg=>'yellow') +table.window_configure([4,-1], :sticky=>:ne, :window=>l) + +# This will get swallowed by a span +l = TkLabel.new(table, :text=>'Window ew', :bg=>'yellow') +table.window_configure([5,3], :sticky=>:ew, :window=>l) + +# This is in the col titles +l = TkLabel.new(table, :text=>'Window news', :bg=>'yellow') +table.window_configure([-5,1], :sticky=>:news, :window=>l) + +l = TkLabel.new(table.winfo_parent, :text=>'Sibling l', :bg=>'orange') +table.window_configure([5,1], :sticky=>:news, :window=>l) + +if table.span_list.empty? + table.set_spans([-1,-2], [0,3], [1,2], [0,5], [3,2], [2,2], [6,0], [4,0]) +end + +puts "Table is #{table.path} with array #{(table['variable'])}" + +# table.postscript(:file=>'out.ps', :first=>:origin, :last=>[2,2]) + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/dynarows.rb b/ext/tk/sample/tkextlib/tktable/dynarows.rb new file mode 100644 index 0000000000..35359046f7 --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/dynarows.rb @@ -0,0 +1,99 @@ +#!/usr/bin/env ruby +## +## dynarows.rb +## +## This demos shows the use of the validation mechanism of the table +## and uses the table's cache (no -command or -variable) with a cute +## dynamic row routine. +## +## ( based on 'dynarows.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +def table_validate(w, idx) + return unless idx =~ /^(\d+),(\d+)$/ + row = Integer($1) + col = Integer($2) + val = w.get(idx) + + [w, idx] + nrows = w[:rows] + return if row == nrows - 1 && val == '' + + begin + time = Tk.tk_call('clock', 'scan', val) + date = [] + Tk.tk_call('clock', 'format', time, + :format=>'%m %d %Y').split(' ').each{|item| + date << item.sub(/^\s*0*/,'') + } + w.set(idx, date.join('/')) + if row == nrows - 1 + if w.get([row,1]) != '' && w.get([row,2]) != '' + w.tag_row_reset(row) + w.set([row,0], row) + nrows += 1 + row += 1 + w.configure(:rows=>nrows) + w.tag_row('unset', row) + w.set([row,0], '*') + w.see([row,1]) + w.activate([row,1]) + end + end + rescue + Tk.bell + w.activate(idx) + w.selection_clear_all + w.selection_set(:active) + w.see(:active) + end +end + + +lbl = TkLabel.new(:text=>"Dynamic Date Validated Rows") + +table = Tk::TkTable.new(:rows=>2, :cols=>3, :cache=>1, :selecttype=>:row, + :titlerows=>1, :titlecols=>1, :height=>5, + :colstretch=>:unset, :rowstretch=>:unset, + :autoclear=>true, + :browsecommand=>[ + proc{|w,s| table_validate(w, s)}, + '%W %s' + ]) +table.set([0,1], 'Begin', [0,2], 'End', [1,0], '*') +table.tag_configure('unset', :fg=>'#008811') +table.tag_configure('title', :fg=>'red') +table.tag_row('unset', 1) +table.set_width(0,3) + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +Tk.grid(lbl, '-', :sticky=>:ew) +Tk.grid(table, sy, :sticky=>:news) +Tk.grid(sx, :sticky=>:ew) + +Tk.root.grid_columnconfig(0, :weight=>1) +Tk.root.grid_rowconfig(1, :weight=>1) + +rtn_proc = proc{|w| + r = w.row_index(:active) + c = w.col_index(:active) + + if c == 2 + r += 1 + w.activate([r,1]) + else + c += 1 + w.activate([r,c]) + end + w.see(:active) + Tk.callback_break +} + +table.bind('Return', rtn_proc, '%W') +table.bind('KP_Enter', rtn_proc, '%W') + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/maxsize.rb b/ext/tk/sample/tkextlib/tktable/maxsize.rb new file mode 100644 index 0000000000..a2c5f606a8 --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/maxsize.rb @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby +## +## maxsize.rb +## +## This demo uses a really big table. The big startup time is in +## filling the table's Tcl array var. +## +## ( based on 'maxsize.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +ary = TkVariable.new_hash +rows = 40000 +cols = 10 + +# fill table variable +((-(rows))..rows).each{|x| + ((-(cols))..cols).each{|y| + ary[x,y] = "#{x},#{y}" + } +} + +lbl = TkLabel.new(:text=>"TkTable v2 Example") + +table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, + :width=>6, :height=>8, + :titlerows=>1, :titlecols=>1, + :coltagcommand=>proc{|col| + col = Integer(col) + return 'OddCol' if col>0 && col%2 == 1 + }, + :selectmode=>:extended, + :colstretch=>:unset, :rowstretch=>:unset, + :selecttitles=>false, :drawmode=>:slow) + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +btn = TkButton.new(:text=>'Exit', :command=>proc{exit}) + +Tk.grid(lbl, '-', :sticky=>:ew) +Tk.grid(table, sy, :sticky=>:news) +Tk.grid(sx, :sticky=>:ew) +Tk.grid(btn, :sticky=>:ew, :columnspan=>2) + +Tk.root.grid_columnconfig(0, :weight=>1) +Tk.root.grid_rowconfig(1, :weight=>1) + +table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink') +table.tag_configure('title', :bg=>'red', :fg=>'blue', :relief=>:sunken) +table.tag_configure('dis', :state=>:disabled) + +first = table[:colorigin] +%w(n s e w nw ne sw se c).each_with_index{|anchor, idx| + table.tag_configure(anchor, :anchor=>anchor) + table.tag_row(anchor, idx) + table.set([idx,first], anchor) +} +courier = TkFont.new(:family=>'Courier', :size=>10) +table.tag_configure('s', :font=>courier, :justify=>:center) + +table.set_width([-2, 8], [-1, 9], [0, 12], [4, 14]) + +puts "Table is #{table.path} with array #{(table['variable'])}" + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/tcllogo.gif b/ext/tk/sample/tkextlib/tktable/tcllogo.gif new file mode 100755 index 0000000000..4603d4ff41 Binary files /dev/null and b/ext/tk/sample/tkextlib/tktable/tcllogo.gif differ diff --git a/ext/tk/sample/tkextlib/tktable/valid.rb b/ext/tk/sample/tkextlib/tktable/valid.rb new file mode 100644 index 0000000000..4570441667 --- /dev/null +++ b/ext/tk/sample/tkextlib/tktable/valid.rb @@ -0,0 +1,88 @@ +#!/usr/bin/env ruby +## +## valid.rb +## +## This demos shows the use of the validation mechanism of the table +## and uses the table's cache (no -command or -variable) +## +## ( based on 'valid.tcl' included source archive of tktable extension ) +## +require 'tk' +require 'tkextlib/tktable' + +rows = 10 +cols = 10 + +def colorize(num) + num = Integer(num) + return 'colored' if (num > 0 && num % 2 == 1) +end + +def fill_headers(w, r=10, c=10) + (1..(r-1)).each{|i| w.set([i,0], i.to_s)} + + (1..(c-1)).each{|j| + if j % 3 == 1 + w.set([0,j], 'AlphaNum') + elsif j % 2 == 1 + w.set([0,j], 'Alpha') + elsif j != 0 + w.set([0,j], 'Real') + end + } +end + +def validate_proc(c, val) + if c % 3 == 1 + # AlphaNum + regexp = /^[A-Za-z0-9 ]*$/ + elsif c % 2 == 1 + # Alpha + regexp = /^[A-Za-z ]*$/ + elsif c != 0 + # 'Real' + regexp = /^[-+]?[0-9]*\.?[0-9]*([0-9]\.?e[-+]?[0-9]*)?$/ + end + if val =~ regexp + return true + else + Tk.bell + return false + end +end + +lbl = TkLabel.new(:text=>"TkTable v1 Validated Table Example") + +table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :cache=>1, + :width=>5, :height=>5, :titlerows=>1, :titlecols=>1, + :coltagcommand=>proc{|n| colorize(n)}, + :flashmode=>true, :selectmode=>:extended, + :colstretch=>:unset, :rowstretch=>:unset, + :validate=>true, + :validatecommand=>proc{|e| + unless e.widget.tag_include?('title', e.index) + validate_proc(e.column, e.new_value) + end } ) + +fill_headers(table) + +table.tag_configure('colored', :bg=>'lightblue') +table.tag_configure('title', :fg=>'red') +table.set_width(0,3) + +sx = table.xscrollbar(TkScrollbar.new) +sy = table.yscrollbar(TkScrollbar.new) + +btn = TkButton.new(:text=>'Exit', :command=>proc{exit}) + +Tk.grid(lbl, '-', :sticky=>:ew) +Tk.grid(table, sy, :sticky=>:news) +Tk.grid(sx, :sticky=>:ew) +Tk.grid(btn, '-', :sticky=>:ew) + +Tk.root.grid_columnconfig(0, :weight=>1) +Tk.root.grid_rowconfig(1, :weight=>1) + +puts "Table is #{table.path}" + +Tk.mainloop diff --git a/ext/tk/sample/tkextlib/vu/LICENSE.orig b/ext/tk/sample/tkextlib/vu/LICENSE.orig index 475f5affae..f5f2f770cf 100644 --- a/ext/tk/sample/tkextlib/vu/LICENSE.orig +++ b/ext/tk/sample/tkextlib/vu/LICENSE.orig @@ -4,7 +4,7 @@ >>> Original Tcl source files are not include in this directry, <<< >>> because of all of them are rewrited to Ruby files. <<< >>> However, the bitmap data file included in this directory is the <<< - >>> same file of vu extension. , the bitmap data file is under the <<< + >>> same file of vu extension. So, the bitmap data file is under the <<< >>> following license. <<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -- cgit v1.2.3