summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/lib/tkextlib/tcllib
diff options
context:
space:
mode:
Diffstat (limited to 'jni/ruby/ext/tk/lib/tkextlib/tcllib')
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/README135
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb158
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb55
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb36
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb151
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb117
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb160
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb97
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb224
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb84
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb134
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb146
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb75
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb47
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb146
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb78
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb1404
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb65
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb79
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb51
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb150
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb28
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb1072
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb43
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb314
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb104
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb65
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb82
39 files changed, 6011 insertions, 0 deletions
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/README b/jni/ruby/ext/tk/lib/tkextlib/tcllib/README
new file mode 100644
index 0000000..441918a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/README
@@ -0,0 +1,135 @@
+
+ [ tcllib extension support files ]
+
+Tcllib includes many utilities. But currently, supports TKLib part
+only (see the following 'tcllib contents').
+
+If you request to support others, please send your message to one of
+ruby-talk/ruby-list/ruby-dev/ruby-ext mailing lists.
+
+-----<from "What is tcllib?">----------------------------
+Tcllib is a collection of utility modules for Tcl. These modules provide
+a wide variety of functionality, from implementations of standard data
+structures to implementations of common networking protocols. The intent
+is to collect commonly used function into a single library, which users
+can rely on to be available and stable.
+---------------------------------------------------------
+
+-----< tcllib contents (based on tcllib-1.6.1) >---------
+Programming tools
+ * cmdline - Procedures to process command lines and options.
+ * comm - A remote communications facility for Tcl (7.6, 8.0, and later)
+ * control - Procedures for control flow structures.
+ * fileutil - Procedures implementing some file utilities
+ * log - Procedures to log messages of libraries and applications.
+ * logger - System to control logging of events.
+ * multiplexer - One-to-many communication with sockets.
+ * snit - Snit's Not Incr Tcl
+ * snitfaq - Snit Frequently Asked Questions
+ * stooop - Object oriented extension.
+ * stoop - Simple Tcl Only Object Oriented Programming
+ * switched - stooop switched class
+ * profiler - Tcl source code profiler
+
+Mathematics
+ * math::statistics - Basic statistical functions and procedures
+ * math::calculus - Integration and ordinary differential equations
+ * math::optimize - Optimisation routines
+ * math::fuzzy - Fuzzy comparison of floating-point numbers
+ * counter - Procedures for counters and histograms
+ * combinatorics - Combinatorial functions in the Tcl Math Library
+
+Data structures
+ * struct::list - Procedures for manipulating lists
+ * struct::set - Procedures for manipulating sets
+ * struct::stack - Create and manipulate stack objects
+ * struct::queue - Create and manipulate queue objects
+ * struct::prioqueue - Create and manipulate prioqueue objects
+ * struct::skiplist - Create and manipulate skiplists
+ * struct::tree - Create and manipulate tree objects
+ * struct::graph - Create and manipulate directed graph objects
+ * struct::record - Define and create records (similar to 'C' structures)
+ * struct::matrix - Create and manipulate matrix objects
+ * struct::pool - Create and manipulate pool objects (of discrete items)
+ * report - Create and manipulate report objects
+
+Text processing
+ * expander - Procedures to process templates and expand text.
+ * base64 - Procedures to encode and decode base64
+ * yencode - encode/decoding a binary file
+ * uuencode - encode/decoding a binary file
+ * csv - Procedures to handle CSV data.
+ * inifile - Parsing of Windows INI files
+ * htmlparse - Procedures to parse HTML strings
+ * mime - Manipulation of MIME body parts
+ * Tcl MIME - generates and parses MIME body parts
+ * textutil - Procedures to manipulate texts and strings.
+ * exif - Tcl EXIF extracts and parses EXIF fields from digital images
+ * EXIF - extract and parse EXIF fields from digital images
+
+Hashes, checksums, and encryption
+ * cksum - calculate a cksum(1) compatible checksum
+ * crc16 - Perform a 16bit Cyclic Redundancy Check
+ * crc32 - Perform a 32bit Cyclic Redundancy Check
+ * des - Perform DES encryption of Tcl data
+ * md4 - MD4 Message-Digest Algorithm
+ * md5 - MD5 Message-Digest Algorithm
+ * ripemd160 - RIPEMD-160 Message-Digest Algorithm
+ * ripemd128 - RIPEMD-128 Message-Digest Algorithm
+ * md5crypt - MD5-based password encryption
+ * sha1 - Perform sha1 hashing
+ * sum - calculate a sum(1) compatible checksum
+ * soundex - Soundex
+
+Documentation tools
+ * mpexpand - Markup processor
+ * doctools - Create and manipulate doctools converter object
+ * doctoc_fmt - Specification of simple tcl markup for table of contents
+ * doctools_api - Interface specification for formatter code
+ * doctools_fmt - Specification of simple tcl markup for manpages
+ * docidx - Create and manipulate docidx converter objects
+ * docidx_api - Interface specification for index formatting code
+ * docidx_fmt - Specification of simple tcl markup for an index
+ * doctoc - Create and manipulate doctoc converter objects
+ * doctoc_api - Interface specification for toc formatting code
+ * doctools::changelog - Handle text in Emacs ChangeLog format
+ * doctools::cvs - Handle text in 'cvs log' format
+
+Networking
+ * uri - URI utilities
+ * dns - Tcl Domain Name Service Client
+ * ntp_time - Tcl Time Service Client
+ * nntp - Tcl client for the NNTP protocol
+ * pop3 - Tcl client for POP3 email protocol
+ * pop3d - Tcl POP3 server implementation
+ * pop3d::udb - Simple user database for pop3d
+ * pop3d::dbox - Simple mailbox database for pop3d
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftpd - Tcl FTP server implementation
+ * smtp - Client-side tcl implementation of the smtp protocol
+ * smtpd - Tcl SMTP server implementation
+ * irc - Create IRC connection and interface.
+
+CGI programming
+ * ncgi - Procedures to manipulate CGI values.
+ * html - Procedures to generate HTML structures
+ * javascript - Procedures to generate HTML and Java Script structures.
+
+Grammars and finite automata
+ * grammar::fa - Create and manipulate finite automatons
+ * grammar::fa::op - Operations on finite automatons
+ * grammar::dacceptor - Create and use deterministic acceptors
+ * grammar::dexec - Execute deterministic finite automatons
+
+TKLib
+ * Plotchart - Simple plotting and charting package
+ * autoscroll - Provides for a scrollbar to automatically mapped and
+ unmapped as needed
+ * ctext - An extended text widget with customizable Syntax highlighting
+ * cursor - Procedures to handle CURSOR data
+ * datefield - Tk datefield widget
+ * style - Changes default Tk look&feel
+ * ipentry - An IP address entry widget
+ * tkpiechart - Creates and dynamically updates 2D or 3D pie charts
+---------------------------------------------------------
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
new file mode 100644
index 0000000..2def59b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
@@ -0,0 +1,158 @@
+#
+# tkextlib/tcllib/autoscroll.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides for a scrollbar to automatically mapped and unmapped as needed
+#
+# (The following is the original description of the library.)
+#
+# This package allows scrollbars to be mapped and unmapped as needed
+# depending on the size and content of the scrollbars scrolled widget.
+# The scrollbar must be managed by either pack or grid, other geometry
+# managers are not supported.
+#
+# When managed by pack, any geometry changes made in the scrollbars parent
+# between the time a scrollbar is unmapped, and when it is mapped will be
+# lost. It is an error to destroy any of the scrollbars siblings while the
+# scrollbar is unmapped. When managed by grid, if anything becomes gridded
+# in the same row and column the scrollbar occupied it will be replaced by
+# the scrollbar when remapped.
+#
+# This package may be used on any scrollbar-like widget as long as it
+# supports the set subcommand in the same style as scrollbar. If the set
+# subcommand is not used then this package will have no effect.
+#
+
+require 'tk'
+require 'tk/scrollbar'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Autoscroll
+ PACKAGE_NAME = 'autoscroll'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('autoscroll')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
+ end
+
+ def self.autoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+
+ def self.unautoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+ end
+ end
+end
+
+module Tk
+ module Scrollable
+ def autoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ def unautoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ end
+end
+
+class Tk::Scrollbar
+ def autoscroll
+ # Arranges for the already existing scrollbar to be mapped
+ # and unmapped as needed.
+ #tk_call_without_enc('::autoscroll::autoscroll', @path)
+ Tk::Tcllib::Autoscroll.autoscroll(self)
+ self
+ end
+ def unautoscroll
+ # Returns the scrollbar to its original static state.
+ #tk_call_without_enc('::autoscroll::unautoscroll', @path)
+ Tk::Tcllib::Autoscroll.unautoscroll(self)
+ self
+ end
+end
+
+# TkPackage.require('autoscroll', '1.0')
+# TkPackage.require('autoscroll', '1.1')
+TkPackage.require('autoscroll')
+
+module Tk
+ module Tcllib
+ class << Autoscroll
+ undef not_available
+ end
+
+ module Autoscroll
+ extend TkCore
+ def self.autoscroll(win)
+ tk_call_without_enc('::autoscroll::autoscroll', win.path)
+ end
+
+ def self.unautoscroll(win)
+ tk_call_without_enc('::autoscroll::unautoscroll', win.path)
+ end
+
+ def self.wrap
+ # v1.1
+ tk_call_without_enc('::autoscroll::wrap')
+ end
+
+ def self.unwrap
+ # v1.1
+ tk_call_without_enc('::autoscroll::unwrap')
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb
new file mode 100644
index 0000000..b6843df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb
@@ -0,0 +1,55 @@
+#
+# tkextlib/tcllib/calendar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * calendar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::calendar', '0.9')
+TkPackage.require('widget::calendar')
+
+module Tk::Tcllib
+ module Widget
+ class Calendar < TkCanvas
+ PACKAGE_NAME = 'widget::calendar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::calendar')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Calendar
+ TkCommandNames = ['::widget::calendar'.freeze].freeze
+
+ def __boolval_optkeys
+ super() << 'showpast'
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def get(what = 'all')
+ tk_send('get', what)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb
new file mode 100644
index 0000000..ba87cd3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb
@@ -0,0 +1,36 @@
+#
+# tkextlib/tcllib/canvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# *
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::canvas_sqmap', '0.2')
+TkPackage.require('widget::canvas_sqmap')
+
+module Tk::Tcllib
+ module Widget
+ class Canvas_Sqmap < Canvas
+ TkCommandNames = ['::widget::canvas_sqmap'.freeze].freeze
+
+ def image_set(cell, img)
+ tk_send('image', 'set', cell, img)
+ self
+ end
+
+ def image_unset(cell)
+ tk_send('image', 'unset', cell)
+ self
+ end
+
+ def flush
+ tk_send('flush')
+ self
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb
new file mode 100644
index 0000000..f4ffb48
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/tcllib/canvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# *
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::canvas_zoom', '0.1')
+TkPackage.require('widget::canvas_zoom')
+
+module Tk::Tcllib
+ module Widget
+ class Canvas_Zoom < Canvas
+ TkCommandNames = ['::widget::canvas_zoom'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb
new file mode 100644
index 0000000..ddb0340
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb
@@ -0,0 +1,151 @@
+#
+# tkextlib/tcllib/chatwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * chatwidget - Provides a multi-paned view suitable for display of
+# chat room or irc channel information
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('chatwidget', '1.1.0')
+TkPackage.require('chatwidget')
+
+module Tk::Tcllib
+ class ChatWidget < TkText
+ PACKAGE_NAME = 'chatwidget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('chatwidget')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ChatWidget
+ TkCommandNames = ['::chatwidget::chatwidget'.freeze].freeze
+
+ def show_topic
+ tk_send_without_enc('topic', 'show')
+ self
+ end
+
+ def hide_topic
+ tk_send_without_enc('topic', 'hide')
+ self
+ end
+
+ def set_topic(topic)
+ tk_send('topic', 'set', topic)
+ end
+
+ def list_name
+ tk_split_simplelist(tk_send('name', 'list'))
+ end
+
+ def list_name_full
+ tk_split_simplelist(tk_send('name', 'list')).map{|lst|
+ nick, *opts = tk_split_simplelist(lst)
+ h_opt = {}
+ opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)}
+ [nick, h_opt]
+ }
+ end
+
+ def add_name(nick, opts={})
+ tk_send('name', 'add', nick, *(hash_kv(opts)))
+ end
+
+ def delete_name(nick)
+ tk_send('name', 'delete', nick)
+ end
+
+ def get_name(nick)
+ lst = tk_send('name', 'get', nick)
+ return nil if lst.empty?
+ nick, *opts = tk_split_simplelist(lst)
+ h_opt = {}
+ opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)}
+ [nick, h_opt]
+ end
+
+ def message(msg, opts={})
+ tk_send('message', msg, *(hash_kv(opts)))
+ self
+ end
+
+ def _parse_hook_list(lst)
+ tk_split_simplelist(lst).map{|hook|
+ cmd, prior = tk_split_simplelist(hook)
+ [procedure(cmd), number(prior)]
+ }
+ end
+ private :_parse_hook_list
+
+ def hook_add(type, *args, &blk) # args -> [prior, cmd], [prior], [cmd]
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+
+ if prior = args.shift
+ if !prior.kind_of?(Numeric)
+ cmd = prior
+ if (prior = args.shift) && !prior.kind_of?(Numeric) # error
+ args.unshift(prior)
+ end
+ args.unshift(cmd)
+ end
+ prior ||= 50 # default priority
+ end
+
+ cmd = args.shift || blk
+
+ fail ArgumentError, "invalid arguments" unless args.empty?
+ fail ArgumentError, "no callback is given" unless cmd
+
+ _parse_hook_list(tk_send('hook', 'add', type, cmd, prior))
+ end
+
+ def hook_remove(type, cmd)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ _parse_hook_list(tk_send('hook', 'remove', type, cmd))
+ end
+
+ def hook_run(type, *cmd_args)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ tk_send('hook', 'run', type, *cmd_args)
+ end
+
+ def hook_list(type)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ _parse_hook_list(tk_send('hook', 'list', type))
+ end
+
+ def show_names
+ tk_send('names', 'show')
+ self
+ end
+
+ def hide_names
+ tk_send('names', 'hide')
+ self
+ end
+
+ def names_widget
+ window(tk_send('names'))
+ end
+
+ def entry_widget
+ window(tk_send('entry'))
+ end
+
+ def chat_widget
+ window(tk_send('chat'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb
new file mode 100644
index 0000000..49b5361
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb
@@ -0,0 +1,117 @@
+#
+# tkextlib/tcllib/crosshair.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Crosshairs for Tk canvas
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('crosshair', '1.0.2')
+TkPackage.require('crosshair')
+
+module Tk::Tcllib
+ module Crosshair
+ PACKAGE_NAME = 'crosshair'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('crosshair')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Crosshair
+ include TkCore
+ TkCommandNames = ['::crosshair::crosshair'.freeze].freeze
+
+ def self.crosshair(w, keys={})
+ Tk.tk_call('::crosshair::crosshair', w, *hash_kv(keys))
+ w
+ end
+ def self.on(w, keys={})
+ self.crosshair(w, keys)
+ end
+
+ def self.off(w)
+ Tk.tk_call('::crosshair::off', w)
+ w
+ end
+
+ def self.track_on(w, &b)
+ Tk.tk_call('::crosshair::track_on', w, b)
+ w
+ end
+
+ def self.track_off(w)
+ Tk.tk_call('::crosshair::track_off', w)
+ w
+ end
+end
+
+class << Tk::Tcllib::Crosshair
+ include TkComm
+ include TkCanvasItemConfig
+
+ def __item_methodcall_optkeys(id)
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ def __item_config_cmd(id)
+ # maybe need to override
+ ['::crosshair::configure', id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def confugure(w, slot, value=None)
+ itemconfigure(w, slot, value)
+ end
+ def confuginfo(w, slot = nil)
+ itemconfiginfo(w, slot)
+ end
+ def current_configinfo(w, slot = nil)
+ current_itemconfiginfo(w, slot)
+ end
+ def cget(w, slot)
+ current_itemconfiginfo(w, slot).values[0]
+ end
+end
+
+module Tk::Tcllib::Crosshair
+ def crosshair_on(keys={})
+ Tk::Tcllib::Crosshair.on(self, keys)
+ end
+ def crosshair_off
+ Tk::Tcllib::Crosshair.off(self)
+ end
+ def crosshair_track_on(&b)
+ Tk::Tcllib::Crosshair.track_on(self, &b)
+ end
+ def crosshair_track_off
+ Tk::Tcllib::Crosshair.track_off(self)
+ end
+ def crosshair_configure(*args)
+ Tk::Tcllib::Crosshair.configure(self, *args)
+ end
+ def crosshair_configinfo(slot = nil)
+ Tk::Tcllib::Crosshair.configinfo(self, slot)
+ end
+ def crosshair_current_configinfo(slot = nil)
+ Tk::Tcllib::Crosshair.current_configinfo(self, slot)
+ end
+ def crosshair_cget(slot)
+ Tk::Tcllib::Crosshair.cget(self, slot)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb
new file mode 100644
index 0000000..308847c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb
@@ -0,0 +1,160 @@
+#
+# tkextlib/tcllib/ctext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Overloads the text widget and provides new commands
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ctext', '3.1')
+TkPackage.require('ctext')
+
+module Tk
+ module Tcllib
+ class CText < Tk::Text
+ PACKAGE_NAME = 'ctext'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ctext')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::CText
+ TkCommandNames = ['ctext'.freeze].freeze
+ WidgetClassName = 'Ctext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'linemapfg' << 'linemapbg' <<
+ 'linemap_select_fg' << 'linemap_select_bg'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'highlight' << 'linemap_markable'
+ end
+ private :__boolval_optkeys
+
+ def append(*args)
+ tk_send('append', *args)
+ end
+
+ def copy
+ tk_send('copy')
+ end
+
+ def cut
+ tk_send('cut')
+ end
+
+ def fast_delete(*args)
+ tk_send('fastdelete', *args)
+ end
+
+ def fast_insert(*args)
+ tk_send('fastinsert', *args)
+ end
+
+ def highlight(*args)
+ tk_send('highlight', *args)
+ end
+
+ def paste
+ tk_send('paste')
+ end
+
+ def edit(*args)
+ tk_send('edit', *args)
+ end
+
+ def add_highlight_class(klass, col, *keywords)
+ tk_call('ctext::addHighlightClass', @path, klass, col, keywords.flatten)
+ self
+ end
+
+ def add_highlight_class_for_special_chars(klass, col, *chrs)
+ tk_call('ctext::addHighlightClassForSpecialChars',
+ @path, klass, col, chrs.join(''))
+ self
+ end
+
+ def add_highlight_class_for_regexp(klass, col, tcl_regexp)
+ tk_call('ctext::addHighlightClassForRegexp',
+ @path, klass, col, tcl_regexp)
+ self
+ end
+
+ def add_highlight_class_with_only_char_start(klass, col, chr)
+ tk_call('ctext::addHighlightClassWithOnlyCharStart',
+ @path, klass, col, chr)
+ self
+ end
+
+ def clear_highlight_classes
+ tk_call('ctext::clearHighlightClasses', @path)
+ self
+ end
+
+ def get_highlight_classes
+ tk_split_simplelist(tk_call('ctext::getHighlightClasses', @path))
+ end
+
+ def delete_highlight_class(klass)
+ tk_call('ctext::deleteHighlightClass', @path, klass)
+ self
+ end
+
+ def enable_C_comments
+ tk_call('ctext::enableComments', @path)
+ self
+ end
+
+ def disable_C_comments
+ tk_call('ctext::disableComments', @path)
+ self
+ end
+
+ def find_next_char(idx, chr)
+ tk_call('ctext::findNextChar', @path, idx, chr)
+ end
+
+ def find_next_space(idx)
+ tk_call('ctext::findNextSpace', @path, idx)
+ end
+
+ def find_previous_space(idx)
+ tk_call('ctext::findPreviousSpace', @path, idx)
+ end
+
+ def set_update_proc(cmd=Proc.new)
+ tk_call('proc', 'ctext::update', '', cmd)
+ self
+ end
+
+ def modified?(mode)
+ bool(tk_call('ctext::modified', @path, mode))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb
new file mode 100644
index 0000000..5c47f97
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb
@@ -0,0 +1,97 @@
+#
+# tkextlib/tcllib/cursor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Procedures to handle CURSOR data
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Cursor
+ PACKAGE_NAME = 'cursor'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('cursor')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
+ end
+
+ def self.cursor_display(win=None)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_propagate(win, cursor)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ Tk::Tcllib::Cursor.not_available
+ end
+ end
+ end
+
+ def self.cursor_display(parent=None)
+ # Pops up a dialog with a listbox containing all the cursor names.
+ # Selecting a cursor name will display it in that dialog.
+ # This is simply for viewing any available cursors on the platform .
+ #tk_call_without_enc('::cursor::display', parent)
+ Tk::Tcllib::Cursor.cursor_display(parent)
+ end
+end
+
+class TkWindow
+ def cursor_propagate(cursor)
+ # Sets the cursor for self and all its descendants to cursor.
+ #tk_call_without_enc('::cursor::propagate', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_propagate(self, cursor)
+ end
+ def cursor_restore(cursor = None)
+ # Restore the original or previously set cursor for self and all its
+ # descendants. If cursor is specified, that will be used if on any
+ # widget that did not have a preset cursor (set by a previous call
+ # to TkWindow#cursor_propagate).
+ #tk_call_without_enc('::cursor::restore', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_restore(self, cursor)
+ end
+end
+
+# TkPackage.require('cursor', '0.1')
+TkPackage.require('cursor')
+
+module Tk
+ module Tcllib
+ class << Cursor
+ undef not_available
+ end
+
+ module Cursor
+ extend TkCore
+ def self.cursor_display(win=None)
+ tk_call_without_enc('::cursor::display', _epath(win))
+ end
+
+ def self.cursor_propagate(win, cursor)
+ #tk_call_without_enc('::cursor::propagate', win.path, cursor)
+ tk_call_without_enc('::cursor::propagate', _epath(win), cursor)
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ #tk_call_without_enc('::cursor::restore', win.path, cursor)
+ tk_call_without_enc('::cursor::restore', _epath(win), cursor)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb
new file mode 100644
index 0000000..77038d9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/tcllib/dateentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * dateentry widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::dateentry', '0.91')
+TkPackage.require('widget::dateentry')
+
+module Tk::Tcllib
+ module Widget
+ class Dateentry < Tk::Tile::TEntry
+ PACKAGE_NAME = 'widget::dateentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::dateentry')
+ rescue
+ ''
+ end
+ end
+ end
+ DateEntry = Dateentry
+ end
+end
+
+class Tk::Tcllib::Widget::Dateentry
+ TkCommandNames = ['::widget::dateentry'.freeze].freeze
+
+ def __strval_optkeys
+ super() << ['dateformat']
+ end
+ private :__strval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def post
+ tk_send('post')
+ self
+ end
+
+ def unpost
+ tk_send('unpost')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb
new file mode 100644
index 0000000..4c2eae7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb
@@ -0,0 +1,57 @@
+#
+# tkextlib/tcllib/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Tk datefield widget
+#
+# (The following is the original description of the library.)
+#
+# The datefield package provides the datefield widget which is an enhanced
+# text entry widget for the purpose of date entry. Only valid dates of the
+# form MM/DD/YYYY can be entered.
+#
+# The datefield widget is, in fact, just an entry widget with specialized
+# bindings. This means all the command and options for an entry widget apply
+# equally here.
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('datefield', '0.1')
+TkPackage.require('datefield')
+
+module Tk
+ module Tcllib
+ class Datefield < Tk::Entry
+ PACKAGE_NAME = 'datefield'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('datefield')
+ rescue
+ ''
+ end
+ end
+ end
+ DateField = Datefield
+ end
+end
+
+class Tk::Tcllib::Datefield
+ TkCommandNames = ['::datefield::datefield'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb
new file mode 100644
index 0000000..d24ba9d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb
@@ -0,0 +1,224 @@
+#
+# tkextlib/tcllib/diagrams.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Draw diagrams
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Diagrams', '0.3')
+TkPackage.require('Diagrams')
+
+module Tk::Tcllib
+ module Diagrams
+ PACKAGE_NAME = 'Diagrams'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Diagrams')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class << Tk::Tcllib::Diagrams
+ include TkCore
+
+ def drawin(canvas)
+ tk_call('::Diagrams::drawin', canvas)
+ canvas
+ end
+ alias draw_in drawin
+
+ def saveps(filename)
+ tk_call('::Diagrams::saveps', filename)
+ filename
+ end
+ alias save_ps saveps
+
+ def direction(dir)
+ tk_call('::Diagrams::direction', dir)
+ dir
+ end
+
+ def currentpos(pos)
+ list(tk_call('::Diagrams::currentpos', pos))
+ end
+ alias current_pos currentpos
+ alias currentpos= currentpos
+ alias current_pos= currentpos
+
+ def getpos(anchor, obj)
+ list(tk_call('::Diagrams::getpos', anchor, obj))
+ end
+ alias get_pos getpos
+
+ def position(x, y)
+ list(tk_call('::Diagrams::position', x, y))
+ end
+
+ def box(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::box', text, width, height))
+ else
+ list(tk_call('::Diagrams::box', text))
+ end
+ end
+
+ def plaintext(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::plaintext', text, width, height))
+ else
+ list(tk_call('::Diagrams::plaintext', text))
+ end
+ end
+
+ def circle(text, radius=nil)
+ if radius
+ list(tk_call('::Diagrams::circle', text, radius))
+ else
+ list(tk_call('::Diagrams::circle', text))
+ end
+ end
+
+ def slanted(text, width=nil, height=nil, angle=nil)
+ if width || height || angle
+ width = '' unless width
+ height = '' unless height
+ if angle
+ list(tk_call('::Diagrams::slanted', text, width, height, angle))
+ else
+ list(tk_call('::Diagrams::slanted', text, width, height))
+ end
+ else
+ list(tk_call('::Diagrams::slanted', text))
+ end
+ end
+
+ def diamond(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::diamond', text, width, height))
+ else
+ list(tk_call('::Diagrams::diamond', text))
+ end
+ end
+
+ def drum(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::drum', text, width, height))
+ else
+ list(tk_call('::Diagrams::drum', text))
+ end
+ end
+
+ def arrow(text=nil, length=nil, head=nil)
+ if length || head
+ text = '' unless text
+ length = '' unless length
+ list(tk_call('::Diagrams::arrow', text, length, head))
+ else
+ if text
+ list(tk_call('::Diagrams::arrow', text))
+ else
+ list(tk_call('::Diagrams::arrow'))
+ end
+ end
+ end
+
+ def line(*args)
+ ary = []
+ args.each{|arg|
+ if arg.kind_of?(Array) && arg.length == 2 # [length, angle]
+ ary.concat arg
+ else # ["POSITION", x, y] or length or angle
+ ary << arg
+ end
+ }
+ list(tk_call('::Diagrams::line', *ary))
+ end
+
+ def bracket(dir, dist, from_pos, to_pos)
+ list(tk_call('::Diagrams::bracket', dir, dist, from_pos, to_pos))
+ end
+
+ def attach(anchor=None)
+ tk_call('::Diagrams::attach', anchor)
+ end
+
+ def color(name=None)
+ tk_call('::Diagrams::color', name)
+ end
+
+ def fillcolor(name=None)
+ tk_call('::Diagrams::fillcolor', name)
+ end
+
+ def textcolor(name=None)
+ tk_call('::Diagrams::textcolor', name)
+ end
+
+ def usegap(mode=None)
+ bool(tk_call('::Diagrams::usegap', mode))
+ end
+ alias use_gap usegap
+
+ def xgap(val=None)
+ number(tk_call('::Diagrams::xgap', val))
+ end
+
+ def ygap(val=None)
+ number(tk_call('::Diagrams::ygap', val))
+ end
+
+ def textfont(fnt=None)
+ tk_call('::Diagrams::textfont', fnt)
+ end
+
+ def linewidth(pixels=None)
+ number(tk_call('::Diagrams::linewidth', pixels))
+ end
+
+ def linestyle(style=None)
+ tk_call('::Diagrams::linestyle', style)
+ end
+
+ def pushstate
+ tk_call('::Diagrams::pushstate')
+ end
+ alias push_state pushstate
+
+ def popstate
+ tk_call('::Diagrams::popstate')
+ end
+ alias pop_state popstate
+
+ def computepos
+ list(tk_call('::Diagrams::computepos'))
+ end
+ alias compute_pos computepos
+
+ def boxcoords(x1, y1, x2, y2)
+ list(tk_call('::Diagrams::boxcoords', x1, y1, x2, y2))
+ end
+
+ def moveobject(obj)
+ list(tk_call('::Diagrams::moveobject', obj))
+ end
+ alias move_object moveobject
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb
new file mode 100644
index 0000000..86a0ef2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb
@@ -0,0 +1,84 @@
+#
+# tkextlib/tcllib/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Generic dialog widget (themed)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::dialog', '1.2')
+TkPackage.require('widget::dialog')
+
+module Tk::Tcllib
+ module Widget
+ class Dialog < TkWindow
+ PACKAGE_NAME = 'widget::dialog'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::dialog')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Dialog
+ TkCommandNames = ['::widget::dialog'.freeze].freeze
+
+ def __boolval_optkeys
+ ['separator', 'synchronous', 'transient']
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def add(what, *args)
+ window(tk_send('add', *args))
+ end
+
+ def get_frame
+ window(tk_send('getframe'))
+ end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+
+ def display
+ tk_send('display')
+ self
+ end
+ alias show display
+
+ def cancel
+ tk_send('cancel')
+ self
+ end
+
+ def close(reason = None)
+ tk_send('close', reason)
+ end
+
+ def withdraw
+ tk_send('withdraw')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb
new file mode 100644
index 0000000..48711d3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb
@@ -0,0 +1,134 @@
+#
+# tkextlib/tcllib/getstring.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A dialog which consists of an Entry, OK, and Cancel buttons.
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('getstring', '0.1')
+TkPackage.require('getstring')
+
+module Tk::Tcllib
+ class GetString_Dialog < TkWindow
+ PACKAGE_NAME = 'getstring'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('getstring')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+
+class Tk::Tcllib::GetString_Dialog
+ TkCommandNames = ['::getstring::tk_getString'.freeze].freeze
+ WidgetClassName = 'TkSDialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def initialize(*args) # args = (parent=nil, text='', keys=nil)
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ text = args.pop
+ @keys = _symbolkey2str(keys)
+ args.push(keys)
+ else
+ text = keys
+ @keys = {}
+ end
+ if text
+ @text = text.dup
+ else
+ @text = ''
+ end
+
+ @variable = TkVariable.new
+ @status = nil
+
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ @variable.value = ''
+ @status = bool(tk_call(self.class::TkCommandNames[0],
+ @path, @variable, @text, *hash_kv(@keys)))
+ end
+ alias display show
+
+ def status
+ @status
+ end
+
+ def value
+ @variable.value
+ end
+
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'text'
+ @text
+ else
+ @keys[slot]
+ end
+ end
+ def cget(slot)
+ cget_strict(slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ if slot == 'text'
+ @text = value.to_s
+ else
+ @keys[slot] = value
+ end
+ else
+ if slot == 'text'
+ @text = ''
+ else
+ @keys.delete(slot)
+ end
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ [ slot, nil, nil, nil, ( (slot == 'text')? @text: @keys[slot] ) ]
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
+ << [ 'text', nil, nil, nil, @text ]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
new file mode 100644
index 0000000..a01a4eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/tcllib/history.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides a history for Entry widgets
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('history', '0.1')
+TkPackage.require('history')
+
+module Tk::Tcllib
+ module History
+ PACKAGE_NAME = 'history'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('history')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::History
+ extend TkCore
+
+ def self.init(entry, length=None)
+ tk_call_without_enc('::history::init', entry.path, length)
+ entry.extend(self) # add methods to treat history to the entry widget
+ end
+
+ def self.remove(entry)
+ tk_call_without_enc('::history::remove', entry.path)
+ entry
+ end
+
+ def history_remove
+ tk_call_without_enc('::history::remove', @path)
+ self
+ end
+
+ def history_add(text)
+ tk_call('::history::add', @path, text)
+ self
+ end
+
+ def history_get
+ simplelist(tk_call_without_enc('::history::get', @path))
+ end
+
+ def history_clear
+ tk_call_without_enc('::history::clear', @path)
+ self
+ end
+
+ def history_configure(opt, value)
+ tk_call('::history::configure', @path, opt, value)
+ self
+ end
+
+ def history_configinfo(opt)
+ tk_call('::history::configure', @path, opt)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb
new file mode 100644
index 0000000..36a32c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb
@@ -0,0 +1,146 @@
+#
+# tkextlib/tcllib/ico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Reading and writing windows icons
+#
+
+require 'tk'
+require 'tk/image'
+#require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ico', '0.3')
+TkPackage.require('ico')
+
+module Tk
+ module Tcllib
+ class ICO < TkImage
+ PACKAGE_NAME = 'ico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ICO
+ def self.list(file, keys=nil)
+ tk_split_list(tk_call_without_enc('::ico::getIconList', file,
+ *hash_kv(keys, true)))
+ end
+
+ def self.icons(file, keys=nil)
+ tk_split_simplelist(tk_call_without_enc('::ico::icons', file,
+ *hash_kv(keys, true))).map{|elem|
+ num_or_str(elem)
+ }
+ end
+
+ def self.get_members(file, name, keys=nil)
+ tk_split_simplelist(tk_call_without_enc('::ico::getMembers', file, name,
+ *hash_kv(keys, true))).map{|elem|
+ name, width, height, bpp = tk_split_simplelist(elem)
+ [name, number(width), number(height), number(bpp)]
+ }
+ end
+
+ def self.get(file, index, keys=nil)
+ tk_call_without_enc('::ico::getIcon', file, index, *hash_kv(keys, true))
+ end
+ def self.get_icon(*args)
+ get(*args)
+ end
+
+ def self.get_by_name(file, name, keys=nil)
+ tk_call_without_enc('::ico::getIconByName', file, name,
+ *hash_kv(keys, true))
+ end
+ def self.get_icon_by_name(*args)
+ get_by_name(*args)
+ end
+
+ def self.get_fileicon(file, keys=nil)
+ tk_call_without_enc('::ico::getFileIcon', file, *hash_kv(keys, true))
+ end
+
+ def self.get_image(file, index, keys={})
+ keys = _symbolkey2str(keys)
+ keys.delete('format')
+ self.new(file, index, keys)
+ end
+
+ def self.get_data(file, index, keys={})
+ keys['format'] = 'data'
+ tk_split_list(tk_call_without_enc('::ico::getIcon', file, index,
+ *hash_kv(keys, true)))
+ end
+
+ def self.write(file, index, depth, data, keys=nil)
+ tk_call_without_enc('::ico::writeIcon', file, index, depth, data,
+ *hash_kv(keys, true))
+ end
+
+ def self.copy(from_file, from_index, to_file, to_index, keys=nil)
+ tk_call_without_enc('::ico::copyIcon',
+ from_file, from_index, to_file, to_index,
+ *hash_kv(keys, true))
+ end
+
+ def self.exe_to_ico(exe_file, ico_file, keys=nil)
+ tk_call_without_enc('::ico::copyIcon', exe_file, ico_file,
+ *hash_kv(keys, true))
+ end
+
+ def self.clear_cache(file=None)
+ tk_call_without_enc('::ico::clearCache', file)
+ end
+
+ def self.transparent_color(image, color)
+ if image.kind_of?(Array)
+ tk_split_list(tk_call_without_enc('::ico::transparentColor',
+ image, color))
+ else
+ tk_call_without_enc('::ico::transparentColor', image, color)
+ end
+ end
+
+ def self.show(file, keys=nil)
+ tk_call_without_enc('::ico::Show', file, *hash_kv(keys, true))
+ end
+
+ ###########################
+
+ def initialize(file, index, keys=nil)
+ keys = _symbolkey2str(keys)
+ if keys.key?('name')
+ @path = keys['name'].to_s
+ else
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
+ end
+ tk_call_without_enc('::ico::getIcon', file, index, '-name', @path,
+ '-format', 'image', *hash_kv(keys, true))
+ Tk_IMGTBL[@path] = self
+ end
+
+ def write(file, index, depth, keys=nil)
+ Tk::Tcllib::ICO.write(file, index, depth, @path, keys=nil)
+ self
+ end
+
+ def transparent_color(color)
+ tk_call_without_enc('::ico::transparentColor', @path, color)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
new file mode 100644
index 0000000..4878cc3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
@@ -0,0 +1,75 @@
+#
+# tkextlib/tcllib/ip_entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * An IP address entry widget
+#
+# (The following is the original description of the library.)
+#
+# This package provides a widget for the entering of a IP address.
+# It guarantees a valid address at all times.
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ipentry', '0.1')
+TkPackage.require('ipentry')
+
+module Tk
+ module Tcllib
+ class IP_Entry < Tk::Entry
+ PACKAGE_NAME = 'ipentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ipentry')
+ rescue
+ ''
+ end
+ end
+ end
+ IPEntry = IP_Entry
+
+ class IP_Entry6 < IP_Entry
+ end
+ IPEntry6 = IP_Entry6
+ IP6_Entry = IP_Entry6
+ end
+end
+
+class Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry'.freeze].freeze
+ WidgetClassName = 'IPEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'fg' << 'bg' << 'insertbackground'
+ end
+ private :__strval_optkeys
+
+ def complete?
+ bool(tk_send_without_enc('complete'))
+ end
+
+ def insert(*ip)
+ tk_send_without_enc('insert', array2tk_list(ip.flatten))
+ end
+end
+
+class Tk::Tcllib::IP_Entry6 < Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry6'.freeze].freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb
new file mode 100644
index 0000000..5dc2130
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/tcllib/khim.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Kevin's Hacky Input Method
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('khim', '1.0')
+TkPackage.require('khim')
+
+module Tk::Tcllib
+ class KHIM < TkToplevel
+ PACKAGE_NAME = 'khim'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('khim')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::KHIM
+ TkCommandNames = ['::khim::getOptions'.freeze].freeze
+
+ def self.get_options(parent='')
+ path = parent + '.tcllib_widget_khim_dialog'
+ self.new(:widgetname => path)
+ end
+
+ def self.get_config #=> cmd_string
+ Tk.tk_call_without_enc('::khim::getConfig')
+ end
+
+ def self.set_config(*args)
+ if args.length == 1
+ # cmd_string generated by
+ #Tk.ip_eval_without_enc(cmd_string)
+ Tk.ip_eval(cmd_string)
+ else
+ # args for setConfig command
+ #Tk.tk_call_without_enc('::khim::setConfig', *args)
+ Tk.tk_call('::khim::setConfig', *args)
+ end
+ end
+
+ def self.showHelp
+ Tk::Tcllib::KHIM::Help.new
+ end
+
+ def create_self(keys=None)
+ @db_class = @classname = nil
+ super(None) # ignore keys
+ end
+end
+
+class Tk::Tcllib::KHIM::Help < TkToplevel
+ TkCommandNames = ['::khim::showHelp'.freeze].freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb
new file mode 100644
index 0000000..f1eb2f2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb
@@ -0,0 +1,47 @@
+#
+# tkextlib/tcllib/menuentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * menuentry widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::menuentry', '1.0')
+TkPackage.require('widget::menuentry')
+
+module Tk::Tcllib
+ module Widget
+ class Menuentry < Tk::Tile::TEntry
+ PACKAGE_NAME = 'widget::menuentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::menuentry')
+ rescue
+ ''
+ end
+ end
+ end
+ MenuEntry = Menuentry
+ end
+end
+
+class Tk::Tcllib::Widget::Menuentry
+ TkCommandNames = ['::widget::menuentry'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb
new file mode 100644
index 0000000..7888ed4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb
@@ -0,0 +1,146 @@
+#
+# tkextlib/tcllib/ntext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Ntext bindtag
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ntext', '0.81')
+TkPackage.require('ntext')
+
+module Tk::Tcllib
+ Ntext = TkBindTag.new_by_name('Ntext')
+end
+
+# variables
+Tk::Tcllib::Ntext.instance_eval{
+ # boolean
+ @classicAnchor = TkVarAccess.new('::ntext::classicAnchor')
+ @classicExtras = TkVarAccess.new('::ntext::classicExtras')
+ @classicMouseSelect = TkVarAccess.new('::ntext::classicMouseSelect')
+ @classicWordBreak = TkVarAccess.new('::ntext::classicWordBreak')
+ @classicWrap = TkVarAccess.new('::ntext::classicWrap')
+ @overwrite = TkVarAccess.new('::ntext::overwrite')
+
+ # regexp
+ @newWrapRegexp = TkVarAccess.new('::ntext::newWrapRegexp')
+
+ # variables (advanced use)
+ @tcl_match_wordBreakAfter = TkVarAccess.new('::ntext::tcl_match_wordBreakAfter')
+ @tcl_match_wordBreakBefore = TkVarAccess.new('::ntext::tcl_match_wordBreakBefore')
+ @tcl_match_endOfWord = TkVarAccess.new('::ntext::tcl_match_endOfWord')
+ @tcl_match_startOfNextWord = TkVarAccess.new('::ntext::tcl_match_startOfNextWord')
+ @tcl_match_startOfPreviousWord = TkVarAccess.new('::ntext::tcl_match_startOfPreviousWord')
+}
+
+class << Tk::Tcllib::Ntext
+ def wrapIndent(txt, *args)
+ TK.tk_call('::next::wrapIndent', txt, *args)
+ end
+
+ def initializeMatchPatterns
+ TK.tk_call('::next::initializeMatchPatterns')
+ self
+ end
+
+ def createMatchPatterns(*args)
+ TK.tk_call('::next::createMatchPatterns', *args)
+ self
+ end
+
+ # functions (advanced use)
+ #ntext::new_wordBreakAfter
+ #ntext::new_wordBreakBefore
+ #ntext::new_endOfWord
+ #ntext::new_startOfNextWord
+ #ntext::new_startOfPreviousWord
+
+ # accessor
+ def classicAnchor
+ @classicAnchor.bool
+ end
+ def classicAnchor=(mode)
+ @classicAnchor.bool = mode
+ end
+
+ def classicExtras
+ @classicExtras.bool
+ end
+ def classicExtras=(mode)
+ @classicExtras.bool = mode
+ end
+
+ def classicMouseSelect
+ @classicMouseSelect.bool
+ end
+ def classicMouseSelect=(mode)
+ @classicMouseSelect.bool = mode
+ end
+
+ def classicWordBreak
+ @classicWordBreak.bool
+ end
+ def classicWordBreak=(mode)
+ @classicWordBreak.bool = mode
+ end
+
+ def classicWrap
+ @classicWrap.bool
+ end
+ def classicWrap=(mode)
+ @classicWrap.bool = mode
+ end
+
+ def overwrite
+ @overwrite.bool
+ end
+ def overwrite=(mode)
+ @classic.bool = mode
+ end
+
+ def newWrapRegexp
+ @newWrapRegexp.value
+ end
+ def newWrapRegexp=(val)
+ @newWrapRegexp.value = val
+ end
+
+ def tcl_match_wordBreakAfter
+ @tcl_match_wordBreakAfter.value
+ end
+ def tcl_match_wordBreakAfter=(val)
+ @tcl_match_wordBreakAfter.value = val
+ end
+
+ def tcl_match_wordBreakBefore
+ @tcl_match_wordBreakBefore.value
+ end
+ def tcl_match_wordBreakBefore=(val)
+ @tcl_match_wordBreakBefore.value = val
+ end
+
+ def tcl_match_endOfWord
+ @tcl_match_endOfWord.value
+ end
+ def tcl_match_endOfWord=(val)
+ @tcl_match_endOfWord.value = val
+ end
+
+ def tcl_match_startOfNextWord
+ @tcl_match_startOfNextWord.value
+ end
+ def tcl_match_startOfNextWord=(val)
+ @tcl_match_startOfNextWord.value = val
+ end
+
+ def tcl_match_startOfPreviousWord
+ @tcl_match_startOfPreviousWord.value
+ end
+ def tcl_match_startOfPreviousWord=(val)
+ @tcl_match_startOfPreviousWord.value = val
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb
new file mode 100644
index 0000000..020c51c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb
@@ -0,0 +1,78 @@
+#
+# tkextlib/tcllib/panelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create PanelFrame widgets.
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::panelframe', '1.0')
+TkPackage.require('widget::panelframe')
+
+module Tk::Tcllib
+ module Widget
+ class PanelFrame < TkWindow
+ PACKAGE_NAME = 'widget::panelframe'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::panelframe')
+ rescue
+ ''
+ end
+ end
+ end
+ Panelframe = PanelFrame
+ end
+end
+
+class Tk::Tcllib::Widget::PanelFrame
+ TkCommandNames = ['::widget::panelframe'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def add(what, *args)
+ window(tk_send('add', *args))
+ end
+
+ #def get_frame
+ # window(tk_send('getframe'))
+ #end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+ def remove_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins)
+ tk_send('delete', *wins)
+ self
+ end
+
+ def items
+ simplelist(tk_send('items')).collect!{|w| window(w)}
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb
new file mode 100644
index 0000000..a1ebe86
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb
@@ -0,0 +1,1404 @@
+#
+# tkextlib/tcllib/plotchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Simple plotting and charting package
+#
+# (The following is the original description of the library.)
+#
+# Plotchart is a Tcl-only package that focuses on the easy creation of
+# xy-plots, barcharts and other common types of graphical presentations.
+# The emphasis is on ease of use, rather than flexibility. The procedures
+# that create a plot use the entire canvas window, making the layout of the
+# plot completely automatic.
+#
+# This results in the creation of an xy-plot in, say, ten lines of code:
+# --------------------------------------------------------------------
+# package require Plotchart
+#
+# canvas .c -background white -width 400 -height 200
+# pack .c -fill both
+#
+# #
+# # Create the plot with its x- and y-axes
+# #
+# set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
+#
+# foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
+# $s plot series1 $x $y
+# }
+#
+# $s title "Data series"
+# --------------------------------------------------------------------
+#
+# A drawback of the package might be that it does not do any data management.
+# So if the canvas that holds the plot is to be resized, the whole plot must
+# be redrawn. The advantage, though, is that it offers a number of plot and
+# chart types:
+#
+# * XY-plots like the one shown above with any number of data series.
+# * Stripcharts, a kind of XY-plots where the horizontal axis is adjusted
+# automatically. The result is a kind of sliding window on the data
+# series.
+# * Polar plots, where the coordinates are polar instead of cartesian.
+# * Isometric plots, where the scale of the coordinates in the two
+# directions is always the same, i.e. a circle in world coordinates
+# appears as a circle on the screen.
+# You can zoom in and out, as well as pan with these plots (Note: this
+# works best if no axes are drawn, the zooming and panning routines do
+# not distinguish the axes), using the mouse buttons with the control
+# key and the arrow keys with the control key.
+# * Piecharts, with automatic scaling to indicate the proportions.
+# * Barcharts, with either vertical or horizontal bars, stacked bars or
+# bars side by side.
+# * Timecharts, where bars indicate a time period and milestones or other
+# important moments in time are represented by triangles.
+# * 3D plots (both for displaying surfaces and 3D bars)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Plotchart', '0.9')
+# TkPackage.require('Plotchart', '1.1')
+# TkPackage.require('Plotchart', '1.6.3')
+TkPackage.require('Plotchart')
+
+module Tk
+ module Tcllib
+ module Plotchart
+ PACKAGE_NAME = 'Plotchart'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Plotchart')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Plotchart
+ extend TkCore
+ ############################
+ def self.view_port(w, *args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', w.path, *(args.flatten))
+ end
+
+ def self.world_coordinates(w, *args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.world_3D_coordinates(w, *args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.coords_to_pixel(w, x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y))
+ end
+
+ def self.coords_3D_to_pixel(w, x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', w.path, x, y, z))
+ end
+
+ def self.plotconfig(*args)
+ case args.length
+ when 0, 1, 2
+ # 0: (no args) --> list of chat types
+ # 1: charttype --> list of components
+ # 2: charttype, component --> list of properties
+ simplelist(tk_call('::Plotchart::plotconfig', *args))
+ when 3
+ # 3: charttype, component, property --> current value
+ tk_call('::Plotchart::plotconfig', *args)
+ else
+ # 4: charttype, component, property, value : set new value
+ # 5+: Error on Tcl/Tk
+ tk_call('::Plotchart::plotconfig', *args)
+ nil
+ end
+ end
+
+ def self.plotpack(w, dir, *plots)
+ tk_call_without_enc('::Plotchart::plotpack', w.path, dir, *plots)
+ w
+ end
+
+ def self.polar_coordinates(w, radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', w.path, radmax)
+ end
+
+ def self.polar_to_pixel(w, rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', w.path, rad, phi))
+ end
+
+ def self.pixel_to_coords(w, x, y)
+ list(tk_call_without_enc('::Plotchart::pixelToCoords', w.path, x, y))
+ end
+
+ def self.determine_scale(*args) # (xmin, xmax, inverted=false)
+ tk_call_without_enc('::Plotchart::determineScale', *args)
+ end
+
+ def self.set_zoom_pan(w)
+ tk_call_without_enc('::Plotchart::setZoomPan', w.path)
+ end
+
+ ############################
+ module ChartMethod
+ include TkCore
+
+ def title(str)
+ tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str))
+ self
+ end
+
+ def save_plot(filename)
+ tk_call_without_enc(@chart, 'saveplot', filename)
+ self
+ end
+
+ def xtext(str)
+ tk_call_without_enc(@chart, 'xtext', _get_eval_enc_str(str))
+ self
+ end
+
+ def ytext(str)
+ tk_call_without_enc(@chart, 'ytext', _get_eval_enc_str(str))
+ self
+ end
+
+ def xconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'xconfig', "-#{key}",value)
+ end
+ self
+ end
+
+ def yconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'yconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def background(part, color_or_image, dir)
+ tk_call_without_enc(@chart, 'background',
+ part, color_or_image, dir)
+ self
+ end
+
+ def xticklines(color=None)
+ tk_call(@chart, 'xticklines', color)
+ self
+ end
+
+ def yticklines(color=None)
+ tk_call(@chart, 'yticklines', color)
+ self
+ end
+
+ def legendconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'legendconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'legendconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def legend(series, text)
+ tk_call_without_enc(@chart, 'legend',
+ _get_eval_enc_str(series), _get_eval_enc_str(text))
+ self
+ end
+
+ def balloon(*args) # args => (x, y, text, dir) or ([x, y], text, dir)
+ if args[0].kind_of?(Array)
+ # args => ([x, y], text, dir)
+ x, y = args.shift
+ else
+ # args => (x, y, text, dir)
+ x = args.shift
+ y = args.shift
+ end
+
+ text, dir = args
+
+ tk_call_without_enc(@chart, 'balloon', x, y,
+ _get_eval_enc_str(text), dir)
+ self
+ end
+
+ def balloonconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'balloonconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'balloonconfig', "-#{key}", value)
+ end
+ end
+
+ def plaintext(*args) # args => (x, y, text, dir) or ([x, y], text, dir)
+ if args[0].kind_of?(Array)
+ # args => ([x, y], text, dir)
+ x, y = args.shift
+ else
+ # args => (x, y, text, dir)
+ x = args.shift
+ y = args.shift
+ end
+
+ text, dir = args
+
+ tk_call_without_enc(@chart, 'plaintext', x, y,
+ _get_eval_enc_str(text), dir)
+ self
+ end
+
+ ############################
+
+ def view_port(*args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', @path, *(args.flatten))
+ self
+ end
+
+ def world_coordinates(*args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def world_3D_coordinates(*args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def coords_to_pixel(x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y))
+ end
+
+ def coords_3D_to_pixel(x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', @path, x, y, z))
+ end
+
+ def plotpack(dir, *plots)
+ tk_call_without_enc('::Plotchart::plotpack', @path, dir, *plots)
+ self
+ end
+
+ def polar_coordinates(radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', @path, radmax)
+ self
+ end
+
+ def polar_to_pixel(rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', @path, rad, phi))
+ end
+
+ def pixel_to_coords(x, y)
+ list(tk_call_without_enc('::Plotchart::pixelToCoords', @path, x, y))
+ end
+
+ def determine_scale(xmax, ymax)
+ tk_call_without_enc('::Plotchart::determineScale', @path, xmax, ymax)
+ self
+ end
+
+ def set_zoom_pan()
+ tk_call_without_enc('::Plotchart::setZoomPan', @path)
+ self
+ end
+ end
+
+ ############################
+ class XYPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXYPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, x, y)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series), x, y)
+ self
+ end
+
+ def contourlines(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourlines', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def contourfill(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourfill', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def contourbox(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourbox', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def color_map(colors)
+ colors = array2tk_list(colors) if colors.kind_of?(Array)
+
+ tk_call_without_enc(@chart, 'colorMap', colors)
+ self
+ end
+
+ def grid_cells(xcrd, ycrd)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+
+ tk_call_without_enc(@chart, 'grid', xcrd, ycrd)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dataconfig', series, "-#{key}", value)
+ end
+ end
+
+ def rescale(xscale, yscale) # xscale|yscale => [newmin, newmax, newstep]
+ tk_call_without_enc(@chart, 'rescale', xscale, yscale)
+ self
+ end
+
+ def trend(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'trend',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+
+ def rchart(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'rchart',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+
+ def interval(series, xcrd, ymin, ymax, ycenter=None)
+ tk_call(@chart, 'interval', series, xcrd, ymin, ymax, ycenter)
+ self
+ end
+
+ def box_and_whiskers(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'box-and-whiskers',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+ alias box_whiskers box_and_whiskers
+
+ def vectorconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'vectorconfig',
+ _get_eval_enc_str(series), *hash_kv(key, true))
+ else
+ tk_call(@chart, 'vectorconfig', series, "-#{key}", value)
+ end
+ self
+ end
+
+ def vector(series, xcrd, ycrd, ucmp, vcmp)
+ tk_call_without_enc(@chart, 'vector', _get_eval_enc_str(series),
+ xcrd, ycrd, ucmp, vcmp)
+ self
+ end
+
+ def dotconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dotconfig',
+ _get_eval_enc_str(series), *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dotconfig', series, "-#{key}", value)
+ end
+ self
+ end
+
+ def dot(series, xcrd, ycrd, value)
+ tk_call_without_enc(@chart, 'dot', _get_eval_enc_str(series),
+ xcrd, ycrd, value)
+ self
+ end
+ end
+
+ ############################
+ class Stripchart < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createStripchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class TXPlot < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTXPlot'.freeze
+ ].freeze
+ end
+
+ ############################
+ class XLogYPlot < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXLogYPlot'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Histogram < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHistogram'.freeze
+ ].freeze
+ end
+
+ ############################
+ class PolarPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPolarplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] radius_data [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @radius_data = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @radius_data = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@radius_data))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, radius, angle)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series),
+ radius, angle)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', _get_eval_enc_str(series),
+ *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dataconfig', series, "-#{key}", value)
+ end
+ end
+ end
+ Polarplot = PolarPlot
+
+ ############################
+ class IsometricPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createIsometricPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, [, step] [, keys])
+ # xaxis := Array of [minimum, maximum]
+ # yaxis := Array of [minimum, maximum]
+ # step := Float of stepsize | "noaxes" | :noaxes
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis),
+ @stepsize)
+ end
+ private :_create_chart
+
+ def plot(type, *args)
+ self.__send__("plot_#{type.to_s.tr('-', '_')}", *args)
+ end
+
+ def plot_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'filled-rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'circle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'filled-circle', *(args.flatten))
+ self
+ end
+ end
+ Isometricplot = IsometricPlot
+
+ ############################
+ class Plot3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, zaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def plot_function(cmd=Proc.new)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfunc', "#{@path}_#{@chart}")
+ self
+ end
+
+ def plot_funcont(conts, cmd=Proc.new)
+ conts = array2tk_list(conts) if conts.kind_of?(Array)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfuncont', "#{@path}_#{@chart}", conts)
+ self
+ end
+
+ def grid_size(nxcells, nycells)
+ tk_call_without_enc(@chart, 'gridsize', nxcells, nycells)
+ self
+ end
+
+ def plot_line(dat, color)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotline', dat, color)
+ self
+ end
+
+ def plot_data(dat)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotdata', dat)
+ self
+ end
+
+ def zconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'zconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'zconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def colour(fill, border)
+ # configure the colours to use for polygon borders and inner area
+ tk_call_without_enc(@chart, 'colour', fill, border)
+ self
+ end
+ alias colours colour
+ alias colors colour
+ alias color colour
+ end
+
+ ############################
+ class Barchart3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DBarchart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] yaxis, nobars [, keys])
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # nobars := number of bars
+ if args[0].kind_of?(Array)
+ @yaxis = args.shift
+ @nobars = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @yaxis = args.shift
+ @nobars = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@yaxis), @nobars)
+ end
+ private :_create_chart
+
+ def plot(label, yvalue, color)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(label),
+ _get_eval_enc_str(yvalue), color)
+ self
+ end
+
+ def config(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'config', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'config', "-#{key}", value)
+ end
+ self
+ end
+ end
+
+ ############################
+ class RibbonChart3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DRibbonChart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] names, yaxis, zaxis [, keys])
+ # names := Array of the series
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @names = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @names = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@names),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def line(*args) # xypairs, color
+ color = args.pop # last argument is a color
+ xypairs = TkComm.slice_ary(args.flatten, 2) # regenerate xypairs
+ tk_call_without_enc(@chart, 'line', xypairs, color)
+ self
+ end
+
+ def area(*args) # xypairs, color
+ color = args.pop # last argument is a color
+ xypairs = TkComm.slice_ary(args.flatten, 2) # regenerate xypairs
+ tk_call_without_enc(@chart, 'area', xypairs, color)
+ self
+ end
+
+ def zconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'zconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'zconfig',"-#{key}", value)
+ end
+ self
+ end
+ end
+
+
+ ############################
+ class Piechart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPiechart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent] [, keys])
+ if args[0].kind_of?(Tk::Canvas)
+ parent = args.shift
+ @path = parent.path
+ else
+ super(*args) # create canvas widget
+ end
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path)
+ end
+ private :_create_chart
+
+ def plot(*dat) # argument is a list of [label, value]
+ tk_call(@chart, 'plot', dat.flatten)
+ self
+ end
+
+ def colours(*list)
+ tk_call_without_enc(@chart, 'colours', *list)
+ self
+ end
+ alias colors colours
+ end
+
+
+ ############################
+ class Radialchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createRadialchart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] names, scale, style [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @names = args.shift
+ @scale = args.shift
+ @style = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @names = args.shift
+ @scale = args.shift
+ @style = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@names), @scale, @style)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(data, color, thickness)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(data),
+ color, thickness)
+ self
+ end
+
+ def colours(*list)
+ tk_call_without_enc(@chart, 'colours', *list)
+ self
+ end
+ alias colors colours
+ end
+
+ ############################
+ class Barchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBarchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] xlabels, ylabels [, series] [, keys])
+ # xlabels, ylabels := labels | axis ( depend on normal or horizontal )
+ # labels := Array of [label, label, ...]
+ # (It determines the number of bars that will be plotted per series.)
+ # axis := Array of [minimum, maximum, stepsize]
+ # series := Integer number of data series | 'stacked' | :stacked
+ if args[0].kind_of?(Array)
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xlabels), array2tk_list(@ylabels),
+ @series_size)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, dat, col=None)
+ tk_call(@chart, 'plot', series, dat, col)
+ self
+ end
+
+ def colours(*cols)
+ # set the colours to be used
+ tk_call(@chart, 'colours', *cols)
+ self
+ end
+ alias colour colours
+ alias colors colours
+ alias color colours
+ end
+
+ ############################
+ class HorizontalBarchart < Barchart
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHorizontalBarchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Boxplot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBoxplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, ylabels [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := List of labels for the y-axis
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @ylabels = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @ylabels = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@ylabels))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(label, *values)
+ tk_call(@chart, 'plot', label, values.flatten)
+ self
+ end
+ end
+
+ ############################
+ class RightAxis < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createRightAxis'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] yaxis [, keys])
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @yaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+ end
+
+ ############################
+ class Timechart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTimechart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # items := Expected/maximum number of items
+ # ( This determines the vertical spacing. )
+ if args[0].kind_of?(String)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, @items)
+ end
+ private :_create_chart
+
+ def period(txt, time_begin, time_end, col=None)
+ tk_call(@chart, 'period', txt, time_begin, time_end, col)
+ self
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call(@chart, 'vertline', txt, time)
+ self
+ end
+
+ def hscroll=(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ scr
+ end
+ def hscroll(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ self
+ end
+
+ def vscroll=(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ scr
+ end
+ def vscroll(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ self
+ end
+ end
+
+ ############################
+ class Ganttchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createGanttchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, text_width] [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # args := Expected/maximum number of items
+ # ( This determines the vertical spacing. ),
+ # Expected/maximum width of items,
+ # Option Hash ( { key=>value, ... } )
+ if args[0].kind_of?(String)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @args = args
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @args = args
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, *args)
+ end
+ private :_create_chart
+
+ def task(txt, time_begin, time_end, completed=0.0)
+ list(tk_call(@chart, 'task', txt, time_begin, time_end,
+ completed)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call(@chart, 'vertline', txt, time)
+ self
+ end
+
+ def connect(from_task, to_task)
+ from_task = array2tk_list(from_task) if from_task.kind_of?(Array)
+ to_task = array2tk_list(to_task) if to_task.kind_of?(Array)
+
+ tk_call(@chart, 'connect', from_task, to_task)
+ self
+ end
+
+ def summary(txt, tasks)
+ tasks = array2tk_list(tasks) if tasks.kind_of?(Array)
+ tk_call(@chart, 'summary', tasks)
+ self
+ end
+
+ def color_of_part(keyword, newcolor)
+ tk_call(@chart, 'color', keyword, newcolor)
+ self
+ end
+
+ def font_of_part(keyword, newfont)
+ tk_call(@chart, 'font', keyword, newfont)
+ self
+ end
+
+ def hscroll=(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ scr
+ end
+ def hscroll(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ self
+ end
+
+ def vscroll=(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ scr
+ end
+ def vscroll(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ self
+ end
+ end
+
+ ############################
+ class PlotSeries < TkObject
+ SeriesID_TBL = TkCore::INTERP.create_table
+
+ (Series_ID = ['series'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TkCore::INTERP.init_ip_env{
+ SeriesID_TBL.mutex.synchronize{ SeriesID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ path = chart.path
+ SeriesID_TBL.mutex.synchronize{
+ if SeriesID_TBL[path]
+ SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(chart, keys=nil)
+ @parent = @chart_obj = chart
+ @ppath = @chart_obj.path
+ Series_ID.mutex.synchronize{
+ @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
+ Series_ID[1].succ!
+ }
+ SeriesID_TBL.mutex.synchronize{
+ SeriesID_TBL[@ppath] ||= {}
+ SeriesID_TBL[@ppath][@id] = self
+ }
+ dataconfig(keys) if keys.kind_of?(Hash)
+ end
+
+ def plot(*args)
+ @chart_obj.plot(@series, *args)
+ end
+
+ def dataconfig(key, value=None)
+ @chart_obj.dataconfig(@series, key, value)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb
new file mode 100644
index 0000000..d22dafa
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb
@@ -0,0 +1,65 @@
+#
+# tkextlib/tcllib/ruler.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * ruler widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::ruler', '1.0')
+TkPackage.require('widget::ruler')
+
+module Tk::Tcllib
+ module Widget
+ class Ruler < TkWindow
+ PACKAGE_NAME = 'widget::ruler'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::ruler')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Ruler
+ TkCommandNames = ['::widget::ruler'.freeze].freeze
+
+ def __boolval_optkeys
+ ['showvalues', 'outline', 'grid']
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ ['interval', 'sizes']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def redraw
+ tk_send('redraw')
+ self
+ end
+
+ def shade(org, dest, frac)
+ tk_send('shade', org, dest, frac)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb
new file mode 100644
index 0000000..75fa36b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/tcllib/screenruler.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * screenruler dialog
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::screenruler', '1.1')
+TkPackage.require('widget::screenruler')
+
+module Tk::Tcllib
+ module Widget
+ class ScreenRuler < TkWindow
+ PACKAGE_NAME = 'widget::ruler'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::screenruler')
+ rescue
+ ''
+ end
+ end
+ end
+ Screenruler = ScreenRuler
+ end
+end
+
+class Tk::Tcllib::Widget::ScreenRuler
+ TkCommandNames = ['::widget::screenruler'.freeze].freeze
+
+ def __boolval_optkeys
+ ['topmost', 'reflect']
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ ['alpha']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def display
+ tk_send('display')
+ self
+ end
+ alias show display
+
+ def hide
+ tk_send('hide')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb
new file mode 100644
index 0000000..c9488b4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb
@@ -0,0 +1,57 @@
+#
+# tkextlib/tcllib/scrolledwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * scrolledwindow widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::scrolledwindow', '1.2')
+TkPackage.require('widget::scrolledwindow')
+
+module Tk::Tcllib
+ module Widget
+ class Scrolledwindow < Tk::Tile::TFrame
+ PACKAGE_NAME = 'widget::scrolledwindow'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::scrolledwindow')
+ rescue
+ ''
+ end
+ end
+ end
+ ScrolledWindow = Scrolledwindow
+ end
+end
+
+class Tk::Tcllib::Widget::ScrolledWindow
+ TkCommandNames = ['::widget::scrolledwindow'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send_without_enc('getframe'))
+ end
+ alias get_frame getframe
+
+ def setwidget(w)
+ window(tk_send_without_enc('setwidget', w))
+ end
+ alias set_widget setwidget
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb
new file mode 100644
index 0000000..c9f6062
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/tcllib/scrollwin.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Scrolled widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::scrolledwindow', '1.0')
+TkPackage.require('widget::scrolledwindow')
+
+module Tk::Tcllib
+ module Widget
+ class ScrolledWindow < TkWindow
+ PACKAGE_NAME = 'widget::scrolledwindow'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::scrolledwindow')
+ rescue
+ ''
+ end
+ end
+ end
+ Scrolledwindow = ScrolledWindow
+ end
+end
+
+class Tk::Tcllib::Widget::ScrolledWindow
+ TkCommandNames = ['::widget::scrolledwindow'.freeze].freeze
+
+ def __numlistval_optkeys
+ ['ipad']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def get_frame
+ window(tk_send('getframe'))
+ end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
new file mode 100644
index 0000000..46a4b9d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
@@ -0,0 +1,79 @@
+#
+# tkextlib/tcllib/statusbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * statusbar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::statusbar', '1.2')
+TkPackage.require('widget::statusbar')
+
+module Tk::Tcllib
+ module Widget
+ class Statusbar < Tk::Tile::TFrame
+ PACKAGE_NAME = 'widget::statusbar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::statusbar')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Statusbar
+ TkCommandNames = ['::widget::statusbar'.freeze].freeze
+
+ def __boolval_optkeys
+ super() << 'separator' << 'resize' << 'resizeseparator'
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send_without_enc('getframe'))
+ end
+ alias get_frame getframe
+
+ def add(w, keys={})
+ window(tk_send_without_enc('setwidget', *(hash_kv(keys))))
+ end
+
+ def remove(*wins)
+ tk_send_without_enc('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send_without_enc('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins)
+ tk_send_without_enc('delete', *wins)
+ self
+ end
+
+ def items(pat=None)
+ tk_split_list(tk_send('items', pat))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb
new file mode 100644
index 0000000..dac6916
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/tcllib/style.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * select and use some 'style' of option (resource) DB
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk::Tcllib
+ module Style
+ PACKAGE_NAME = 'style'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('style')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/style' extension is not available on your current environment."
+ end
+
+ def self.names
+ Tk::Tcllib::Style.not_available
+ end
+
+ def self.use(style)
+ Tk::Tcllib::Style.not_available
+ end
+ end
+end
+
+# TkPackage.require('style', '0.1')
+# TkPackage.require('style', '0.3')
+TkPackage.require('style')
+
+module Tk::Tcllib
+ class << Style
+ undef not_available
+ end
+
+ module Style
+ extend TkCore
+
+ def self.names
+ tk_split_simplelist(tk_call('style::names'))
+ end
+
+ def self.use(style)
+ tk_call('style::use', style)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb
new file mode 100644
index 0000000..adc9c4a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb
@@ -0,0 +1,51 @@
+#
+# tkextlib/tcllib/superframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Superframe widget - enhanced labelframe widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::superframe', '1.0')
+TkPackage.require('widget::superframe')
+
+module Tk::Tcllib
+ module Widget
+ class SuperFrame < TkWindow
+ PACKAGE_NAME = 'widget::superframe'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::superframe')
+ rescue
+ ''
+ end
+ end
+ end
+ Superframe = SuperlFrame
+ end
+end
+
+class Tk::Tcllib::Widget::SuperFrame
+ TkCommandNames = ['::widget::superframe'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def labelwidget
+ window(tk_send('labelwidget'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb
new file mode 100644
index 0000000..7698640
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb
@@ -0,0 +1,150 @@
+#
+# tkextlib/tcllib/swaplist.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A dialog which allows a user to move options between two lists
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('swaplist', '0.1')
+TkPackage.require('swaplist')
+
+module Tk::Tcllib
+ class Swaplist_Dialog < TkWindow
+ PACKAGE_NAME = 'swaplist'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('swaplist')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+
+class Tk::Tcllib::Swaplist_Dialog
+ TkCommandNames = ['::swaplist::swaplist'.freeze].freeze
+ WidgetClassName = 'Swaplist'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def initialize(*args)
+ # args = (parent=nil, complete_list=[], selected_list=[], keys=nil)
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ @selected_list = args.pop
+ @complete_list = args.pop
+ @keys = _symbolkey2str(keys)
+ args.push(keys)
+ else
+ @selected_list = keys
+ @complete_list = args.pop
+ @keys = {}
+ end
+
+ @selected_list = [] unless @selected_list
+ @complete_list = [] unless @complete_list
+
+ @variable = TkVariable.new
+ @status = nil
+
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ @variable.value = ''
+ @status = bool(tk_call(self.class::TkCommandNames[0],
+ @path, @variable,
+ @complete_list, @selected_list,
+ *hash_kv(@keys)))
+ end
+ alias display show
+
+ def status
+ @status
+ end
+
+ def value
+ @variable.list
+ end
+ alias selected value
+
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'complete_list'
+ @complete_list
+ elsif slot == 'selected_list'
+ @selected_list
+ else
+ @keys[slot]
+ end
+ end
+ def cget(slot)
+ cget_strict(slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ if slot == 'complete_list'
+ @complete_list = value
+ elsif slot == 'selected_list'
+ @selected_list = value
+ else
+ @keys[slot] = value
+ end
+ else
+ if slot == 'complete_list'
+ @complete_list = []
+ elsif slot == 'selected_list'
+ @selected_list = []
+ else
+ @keys.delete(slot)
+ end
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ if slot == 'complete_list'
+ [ slot, nil, nil, nil, @complete_list ]
+ elsif slot == 'selected_list'
+ [ slot, nil, nil, nil, @selected_list ]
+ else
+ [ slot, nil, nil, nil, @keys[slot] ]
+ end
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
+ << [ 'complete_list', nil, nil, nil, @complete_list ] \
+ << [ 'selected_list', nil, nil, nil, @selected_list ]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb
new file mode 100644
index 0000000..bf5ab66
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb
@@ -0,0 +1,28 @@
+#
+# tkextlib/tcllib/tablelist.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A multi-column listbox
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# check Tile extension :: If already loaded, use tablelist_tile.
+unless defined? Tk::Tcllib::Tablelist_usingTile
+ Tk::Tcllib::Tablelist_usingTile =
+ TkPackage.provide('tile') || TkPackage.provide('Ttk')
+end
+
+if Tk::Tcllib::Tablelist_usingTile
+ # with Tile
+ require 'tkextlib/tcllib/tablelist_tile'
+
+else
+ # without Tile
+
+ # TkPackage.require('tablelist', '4.2')
+ TkPackage.require('tablelist')
+
+ require 'tkextlib/tcllib/tablelist_core'
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
new file mode 100644
index 0000000..2a5c415
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
@@ -0,0 +1,1072 @@
+#
+# tkextlib/tcllib/tablelist_core.rb
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * This file is required by 'tkextlib/tcllib/tablelist.rb' or
+# 'tkextlib/tcllib/tablelist_tile.rb'.
+#
+
+module Tk
+ module Tcllib
+ class Tablelist < TkWindow
+ if Tk::Tcllib::Tablelist_usingTile
+ PACKAGE_NAME = 'Tablelist_tile'.freeze
+ else
+ PACKAGE_NAME = 'Tablelist'.freeze
+ end
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require(self.package_name)
+ rescue
+ ''
+ end
+ end
+
+ def self.use_Tile?
+ (Tk::Tcllib::Tablelist_usingTile)? true: false
+ end
+ end
+ TableList = Tablelist
+ end
+end
+
+module Tk::Tcllib::TablelistItemConfig
+ include TkItemConfigMethod
+
+ def _to_idx(idx)
+ if idx.kind_of?(Array)
+ idx.collect{|elem| _get_eval_string(elem)}.join(',')
+ else
+ idx
+ end
+ end
+ def _from_idx(idx)
+ return idx unless idx.kind_of?(String)
+
+ if idx[0] == ?@ # '@x,y'
+ idx
+ elsif idx =~ /([^,]+),([^,]+)/
+ row = $1, column = $2
+ [num_or_str(row), num_or_str(column)]
+ else
+ num_or_str(idx)
+ end
+ end
+ private :_to_idx, :_from_idx
+
+ def __item_cget_cmd(mixed_id)
+ [self.path, mixed_id[0] + 'cget', _to_idx(mixed_id[1])]
+ end
+ def __item_config_cmd(mixed_id)
+ [self.path, mixed_id[0] + 'configure', _to_idx(mixed_id[1])]
+ end
+
+ def cell_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['cell', tagOrId], option)
+ end
+ def cell_cget(tagOrId, option)
+ itemcget(['cell', tagOrId], option)
+ end
+ def cell_cget_strict(tagOrId, option)
+ itemcget_strict(['cell', tagOrId], option)
+ end
+ def cell_configure(tagOrId, slot, value=None)
+ itemconfigure(['cell', tagOrId], slot, value)
+ end
+ def cell_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['cell', tagOrId], slot)
+ end
+ def current_cell_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['cell', tagOrId], slot)
+ end
+ alias cellcget_tkstring cell_cget_tkstring
+ alias cellcget cell_cget
+ alias cellcget_strict cell_cget_strict
+ alias cellconfigure cell_configure
+ alias cellconfiginfo cell_configinfo
+ alias current_cellconfiginfo current_cell_configinfo
+
+ def column_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['column', tagOrId], option)
+ end
+ def column_cget(tagOrId, option)
+ itemcget(['column', tagOrId], option)
+ end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
+ def column_configure(tagOrId, slot, value=None)
+ itemconfigure(['column', tagOrId], slot, value)
+ end
+ def column_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['column', tagOrId], slot)
+ end
+ def current_column_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['column', tagOrId], slot)
+ end
+ alias columncget_tkstring column_cget_tkstring
+ alias columncget column_cget
+ alias columncget_strict column_cget_strict
+ alias columnconfigure column_configure
+ alias columnconfiginfo column_configinfo
+ alias current_columnconfiginfo current_column_configinfo
+
+ def row_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['row', tagOrId], option)
+ end
+ def row_cget(tagOrId, option)
+ itemcget(['row', tagOrId], option)
+ end
+ def row_cget_strict(tagOrId, option)
+ itemcget_strict(['row', tagOrId], option)
+ end
+ def row_configure(tagOrId, slot, value=None)
+ itemconfigure(['row', tagOrId], slot, value)
+ end
+ def row_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['row', tagOrId], slot)
+ end
+ def current_row_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['row', tagOrId], slot)
+ end
+ alias rowcget_tkstring row_cget_tkstring
+ alias rowcget row_cget
+ alias rowcget_strict row_cget_strict
+ alias rowconfigure row_configure
+ alias rowconfiginfo row_configinfo
+ alias current_rowconfiginfo current_row_configinfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::Tcllib::Tablelist
+ include Tk::Tcllib::TablelistItemConfig
+ include Scrollable
+
+ TkCommandNames = ['::tablelist::tablelist'.freeze].freeze
+ WidgetClassName = 'Tablelist'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ ##########################
+
+ def __numval_optkeys
+ super() + ['titlecolumns']
+ end
+ private :__numval_optkeys
+
+ def __strval_optkeys
+ super() + ['snipstring']
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() - ['takefocus'] + [
+ 'forceeditendcommand', 'movablecolumns', 'movablerows',
+ 'protecttitlecolumns', 'resizablecolumns', 'setfocus',
+ 'showarrow', 'showlabels', 'showseparators'
+ ]
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() + ['columns', 'columntitles']
+ end
+ private :__listval_optkeys
+
+ def __tkvariable_optkeys
+ super() + ['listvariable']
+ end
+ private :__tkvariable_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ super().update('stretch'=>proc{|v|
+ (v == 'all')? v: simplelist(v)
+ },
+ 'takefocus'=>proc{|v|
+ case v
+ when '1'
+ true
+ when '0'
+ false
+ when ''
+ nil
+ else # cmd
+ tk_tcl2ruby(cmd)
+ end
+ })
+ end
+ private :__val2ruby_optkeys
+
+ def __ruby2val_optkeys # { key=>proc, ... }
+ # The method is used to convert a ruby's object to a opt-value.
+ # When set the value of the option "key", "proc.call(value)" is called.
+ # That is, "-#{key} #{proc.call(value)}".
+ super().update('stretch'=>proc{|v|
+ (v.kind_of?(Array))? v.collect{|e| _to_idx(e)}: v
+ },
+ 'takefocus'=>proc{|v|
+ case v
+ when true
+ '1'
+ when false
+ '0'
+ when nil
+ ''
+ else
+ _get_eval_string(v)
+ end
+ })
+ end
+ private :__ruby2val_optkeys
+
+ def __font_optkeys
+ super() + ['labelfont']
+ end
+ private :__font_optkeys
+
+ ##########################
+
+ def __item_strval_optkeys(id)
+ if id[0] == 'cell'
+ super(id) + ['title']
+ else
+ super(id) - ['text'] + ['title', 'name']
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_boolval_optkeys(id)
+ super(id) + [
+ 'changesnipside', 'editable', 'hide', 'resizable', 'selectable',
+ 'showarrow', 'showlinenumbers', 'stretchable', 'stretchwindow', 'wrap'
+ ]
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ if id[0] == 'cell'
+ super(id)
+ else
+ super(id) + ['text']
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_font_optkeys(id)
+ # maybe need to override
+ super(id) + ['labelfont']
+ end
+ private :__item_font_optkeys
+
+ ##########################
+
+ def activate(index)
+ tk_send('activate', _to_idx(index))
+ self
+ end
+
+ def activate_cell(index)
+ tk_send('activatecell', _to_idx(index))
+ self
+ end
+ alias activatecell activate_cell
+
+ def get_attrib(name=nil)
+ if name && name != None
+ tk_send('attrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('attrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_attrib(*args)
+ tk_send('attrib', *(args.flatten))
+ self
+ end
+
+ def bbox(index)
+ list(tk_send('bbox', _to_idx(index)))
+ end
+
+ def bodypath
+ window(tk_send('bodypath'))
+ end
+
+ def bodytag
+ TkBindTag.new_by_name(tk_send('bodytag'))
+ end
+
+ def cancel_editing
+ tk_send('cancelediting')
+ self
+ end
+ alias cancelediting cancel_editing
+
+ def get_cellattrib(name=nil)
+ if name && name != None
+ tk_send('cellattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('cellattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_cellattrib(*args)
+ tk_send('cellattrib', *(args.flatten))
+ self
+ end
+
+ def cellindex(idx)
+ _from_idx(tk_send('cellindex', _to_idx(idx)))
+ end
+
+ def cellselection_anchor(idx)
+ tk_send('cellselection', 'anchor', _to_idx(idx))
+ self
+ end
+
+ def cellselection_clear(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('cellselection', 'clear', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('cellselection', 'clear', first, last)
+ end
+ self
+ end
+
+ def cellselection_includes(idx)
+ bool(tk_send('cellselection', 'includes', _to_idx(idx)))
+ end
+
+ def cellselection_set(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('cellselection', 'set', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('cellselection', 'set', first, last)
+ end
+ self
+ end
+
+ def get_columnattrib(name=nil)
+ if name && name != None
+ tk_send('columnattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('columnattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_columnattrib(*args)
+ tk_send('columnattrib', *(args.flatten))
+ self
+ end
+
+ def columncount
+ number(tk_send('columncount'))
+ end
+
+ def columnindex(idx)
+ number(tk_send('columnindex', _to_idx(idx)))
+ end
+
+ def columnwidth(idx, opt=nil)
+ if opt
+ number(tk_send('columnwidth', _to_idx(idx), "-#{opt}"))
+ else
+ number(tk_send('columnwidth', _to_idx(idx)))
+ end
+ end
+ def requested_columnwidth(idx)
+ columnwidth(idx, 'requested')
+ end
+ def stretched_columnwidth(idx)
+ columnwidth(idx, 'stretched')
+ end
+ def total_columnwidth(idx)
+ columnwidth(idx, 'total')
+ end
+
+ def configcelllist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcelllist', ary)
+ self
+ end
+ alias config_celllist configcelllist
+
+ def configcells(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcells', *ary)
+ self
+ end
+ alias config_cells configcells
+
+ def configcolumnlist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcolumnlist', ary)
+ self
+ end
+ alias config_columnlist configcolumnlist
+
+ def configcolumns(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcolumns', *ary)
+ self
+ end
+ alias config_columns configcolumns
+
+ def configrowlist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configrowlist', ary)
+ self
+ end
+ alias config_rowlist configrowlist
+
+ def configrows(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configrows', *ary)
+ self
+ end
+ alias config_rows configrows
+
+ def containing(y)
+ idx = num_or_str(tk_send('containing', y))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+
+ def containing_cell(x, y)
+ idx = _from_idx(tk_send('containingcell', x, y))
+ if idx.kind_of?(Array)
+ [
+ ((idx[0].kind_of?(Fixnum) && idx[0] < 0)? nil: idx[0]),
+ ((idx[1].kind_of?(Fixnum) && idx[1] < 0)? nil: idx[1])
+ ]
+ else
+ idx
+ end
+ end
+ alias containingcell containing_cell
+
+ def containing_column(x)
+ idx = num_or_str(tk_send('containingcolumn', x))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+ alias containingcolumn containing_column
+
+ def curcellselection
+ simplelist(tk_send('curcellselection')).collect!{|idx| _from_idx(idx)}
+ end
+
+ def curselection
+ list(tk_send('curselection'))
+ end
+
+ def delete_items(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('delete', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('delete', first, last)
+ end
+ self
+ end
+ alias delete delete_items
+ alias deleteitems delete_items
+
+ def delete_columns(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('deletecolumns', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('deletecolumns', first, last)
+ end
+ self
+ end
+ alias deletecolumns delete_columns
+
+ def edit_cell(idx)
+ tk_send('editcell', _to_idx(idx))
+ self
+ end
+ alias editcell edit_cell
+
+ def editwintag
+ TkBindTag.new_by_name(tk_send('editwintag'))
+ end
+
+ def editwinpath
+ window(tk_send('editwinpath'))
+ end
+
+ def entrypath
+ window(tk_send('entrypath'))
+ end
+
+ def fill_column(idx, txt)
+ tk_send('fillcolumn', _to_idx(idx), txt)
+ self
+ end
+ alias fillcolumn fill_column
+
+ def finish_editing
+ tk_send('finishediting')
+ self
+ end
+ alias finishediting finish_editing
+
+ def formatinfo
+ key, row, col = simplelist(tk_send('formatinfo'))
+ [key, number(row), number(col)]
+ end
+
+ def get(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('get', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('get', first, last))
+ end
+ end
+
+ def get_cells(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getcells', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getcells', first, last))
+ end
+ end
+ alias getcells get_cells
+
+ def get_columns(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getcolumns', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getcolumns', first, last))
+ end
+ end
+ alias getcolumns get_columns
+
+ def get_keys(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getkeys', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getkeys', first, last))
+ end
+ end
+ alias getkeys get_keys
+
+ def has_attrib?(name)
+ bool(tk_send('hasattrib', name))
+ end
+
+ def has_cellattrib?(idx, name)
+ bool(tk_send('hascellattrib', _to_idx(idx), name))
+ end
+
+ def has_columnattrib?(idx, name)
+ bool(tk_send('hascolumnattrib', _to_idx(idx), name))
+ end
+
+ def has_rowattrib?(idx, name)
+ bool(tk_send('hasrowattrib', _to_idx(idx), name))
+ end
+
+ def imagelabelpath(idx)
+ window(tk_send('imagelabelpath', _to_idx(idx)))
+ end
+
+ def index(idx)
+ number(tk_send('index', _to_idx(idx)))
+ end
+
+ def insert(idx, *items)
+ tk_send('insert', _to_idx(idx), *items)
+ self
+ end
+
+ def insert_columnlist(idx, columnlist)
+ tk_send('insertcolumnlist', _to_idx(idx), columnlist)
+ self
+ end
+ alias insertcolumnlist insert_columnlist
+
+ def insert_columns(idx, *args)
+ tk_send('insertcolums', _to_idx(idx), *args)
+ self
+ end
+ alias insertcolumns insert_columns
+
+ def insert_list(idx, list)
+ tk_send('insertlist', _to_idx(idx), list)
+ self
+ end
+ alias insertlist insert_list
+
+ def is_elem_snipped?(cellidx, tkvar)
+ bool(tk_send('iselemsnipped', _to_idx(cellidx), tkvar))
+ end
+ alias elem_snipped? is_elem_snipped?
+
+ def is_title_snipped?(colidx, tkvar)
+ bool(tk_send('istitlesnipped', _to_idx(colidx), tkvar))
+ end
+ alias title_snipped? is_title_snipped?
+
+ def itemlistvar
+ TkVarAccess.new(tk_send('itemlistvar'))
+ end
+
+ def labelpath(idx)
+ window(tk_send('labelpath', _to_idx(idx)))
+ end
+
+ def labels
+ simplelist(tk_send('labels'))
+ end
+
+ def labeltag
+ TkBindTag.new_by_name(tk_send('labeltag'))
+ end
+
+ def move(src, target)
+ tk_send('move', _to_idx(src), _to_idx(target))
+ self
+ end
+
+ def move_column(src, target)
+ tk_send('movecolumn', _to_idx(src), _to_idx(target))
+ self
+ end
+ alias movecolumn move_column
+
+ def nearest(y)
+ _from_idx(tk_send('nearest', y))
+ end
+
+ def nearest_cell(x, y)
+ _from_idx(tk_send('nearestcell', x, y))
+ end
+ alias nearestcell nearest_cell
+
+ def nearest_column(x)
+ _from_idx(tk_send('nearestcolumn', x))
+ end
+ alias nearestcolumn nearest_column
+
+ def reject_input
+ tk_send('rejectinput')
+ self
+ end
+ alias rejectinput reject_input
+
+ def reset_sortinfo
+ tk_send('resetsortinfo')
+ self
+ end
+ alias resetsortinfo reset_sortinfo
+
+ def get_rowattrib(name=nil)
+ if name && name != None
+ tk_send('rowattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('rowattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_rowattrib(*args)
+ tk_send('rowattrib', *(args.flatten))
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send('scan', 'mark', x, y)
+ self
+ end
+
+ def scan_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(idx)
+ tk_send('see', _to_idx(idx))
+ self
+ end
+
+ def see_cell(idx)
+ tk_send('seecell', _to_idx(idx))
+ self
+ end
+ alias seecell see_cell
+
+ def see_column(idx)
+ tk_send('seecolumn', _to_idx(idx))
+ self
+ end
+ alias seecolumn see_column
+
+ def selection_anchor(idx)
+ tk_send('selection', 'anchor', _to_idx(idx))
+ self
+ end
+
+ def selection_clear(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('selection', 'clear', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('selection', 'clear', first, last)
+ end
+ self
+ end
+
+ def selection_includes(idx)
+ bool(tk_send('selection', 'includes', _to_idx(idx)))
+ end
+
+ def selection_set(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('selection', 'set', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('selection', 'set', first, last)
+ end
+ self
+ end
+
+ def separatorpath(idx=nil)
+ if idx
+ window(tk_send('separatorpath', _to_idx(idx)))
+ else
+ window(tk_send('separatorpath'))
+ end
+ end
+
+ def separators
+ simplelist(tk_send('separators')).collect!{|w| window(w)}
+ end
+
+ def size
+ number(tk_send('size'))
+ end
+
+ def sort(order=nil)
+ if order
+ order = order.to_s
+ order = '-' << order if order[0] != ?-
+ if order.length < 2
+ order = nil
+ end
+ end
+ if order
+ tk_send('sort', order)
+ else
+ tk_send('sort')
+ end
+ self
+ end
+ def sort_increasing
+ tk_send('sort', '-increasing')
+ self
+ end
+ def sort_decreasing
+ tk_send('sort', '-decreasing')
+ self
+ end
+
+
+ # default of 'labelcommand' option
+ DEFAULT_labelcommand_value =
+ DEFAULT_sortByColumn_cmd = '::tablelist::sortByColumn'
+
+ # default of 'labelcommand2' option
+ DEFAULT_labelcommand2_value =
+ DEFAULT_addToSortColumns_cmd = '::tablelist::addToSortColumns'
+
+ def sortByColumn_with_event_generate(idx)
+ tk_call('::tablelist::sortByColumn', @path, _to_idx(idx))
+ end
+
+ def addToSortColumns_with_event_generate(idx)
+ tk_call('::tablelist::addToSortColumns', @path, _to_idx(idx))
+ end
+
+ def sort_by_column(idx, order=nil)
+ if order
+ order = order.to_s
+ order = '-' << order if order[0] != ?-
+ if order.length < 2
+ order = nil
+ end
+ end
+ if order
+ tk_send('sortbycolumn', _to_idx(idx), order)
+ else
+ tk_send('sortbycolumn', _to_idx(idx))
+ end
+ self
+ end
+ def sort_by_column_increasing(idx)
+ tk_send('sortbycolumn', _to_idx(idx), '-increasing')
+ self
+ end
+ def sort_by_column_decreasing(idx)
+ tk_send('sortbycolumn', _to_idx(idx), '-decreasing')
+ self
+ end
+
+ def sort_by_columnlist(idxlist, orderlist=None)
+ # orderlist :: list of 'increasing' or 'decreasing'
+ tk_send('sortbycolumnlist', idxlist.map{|idx| _to_idx(idx)}, orderlist)
+ self
+ end
+
+ def sortcolumn
+ idx = num_or_str(tk_send('sortcolum'))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+
+ def sortcolumnlist
+ simplelist(tk_send('sortcolumlist')).map{|col| num_or_str(col)}
+ end
+
+ def sortorder
+ tk_send('sortorder')
+ end
+
+ def sortorderlist
+ simplelist(tk_send('sortorderlist'))
+ end
+
+ def toggle_columnhide(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglecolumnhide', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglecolumnhide', first, last)
+ end
+ end
+
+ def toggle_rowhide(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglerowhide', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglerowhide', first, last)
+ end
+ end
+
+ def toggle_visibility(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglevisibility', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglevisibility', first, last)
+ end
+ self
+ end
+ alias togglevisibility toggle_visibility
+
+ def unset_attrib(name)
+ tk_send('unsetattrib', name)
+ self
+ end
+
+ def unset_cellattrib(idx, name)
+ tk_send('unsetcellattrib', _to_idx(idx), name)
+ self
+ end
+
+ def unset_columnattrib(idx, name)
+ tk_send('unsetcolumnattrib', _to_idx(idx), name)
+ self
+ end
+
+ def unset_rowattrib(idx, name)
+ tk_send('unsetrowattrib', _to_idx(idx), name)
+ self
+ end
+
+ def windowpath(idx)
+ window(tk_send('windowpath', _to_idx(idx)))
+ end
+end
+
+class << Tk::Tcllib::Tablelist
+ ############################################################
+ # helper commands
+ def getTablelistPath(descendant)
+ window(Tk.tk_call('::tablelist::getTablelistPath', descendant))
+ end
+
+ def getTablelistColumn(descendant)
+ num_or_str(Tk.tk_call('::tablelist::getTablelistColumn', headerlabel))
+ end
+
+
+ def convEventFields(descendant, x, y)
+ window(Tk.tk_call('::tablelist::convEventFields', descendant, x, y))
+ end
+
+
+ ############################################################
+ # with the BWidget package
+ def addBWidgetEntry(name=None)
+ Tk.tk_call('::tablelist::addBWidgetEntry', name)
+ end
+
+ def addBWidgetSpinBox(name=None)
+ Tk.tk_call('::tablelist::addBWidgetSpinBox', name)
+ end
+
+ def addBWidgetComboBox(name=None)
+ Tk.tk_call('::tablelist::addBWidgetComboBox', name)
+ end
+
+
+ ############################################################
+ # with the Iwidgets ([incr Widgets]) package
+ def addIncrEntryfield(name=None)
+ Tk.tk_call('::tablelist::addIncrEntry', name)
+ end
+
+ def addIncrDateTimeWidget(type, seconds=false, name=None)
+ # type := 'datefield'|'dateentry'|timefield'|'timeentry'
+ if seconds && seconds != None
+ seconds = '-seconds'
+ else
+ seconds = None
+ end
+ Tk.tk_call('::tablelist::addDateTimeWidget', type, seconds, name)
+ end
+
+ def addIncrSpinner(name=None)
+ Tk.tk_call('::tablelist::addIncrSpinner', name)
+ end
+
+ def addIncrSpinint(name=None)
+ Tk.tk_call('::tablelist::addIncrSpinint', name)
+ end
+
+ def addIncrCombobox(name=None)
+ Tk.tk_call('::tablelist::addIncrCombobox', name)
+ end
+
+
+ ############################################################
+ # with Bryan Oakley's combobox package
+ def addOakleyCombobox(name=None)
+ Tk.tk_call('::tablelist::addOakleyCombobox', name)
+ end
+
+ ############################################################
+ # with the multi-entry package Mentry is a library extension
+ def addDateMentry(format, separator, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addDateMentry', format, separator, gmt, name)
+ end
+
+ def addTimeMentry(format, separator, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addTimeMentry', format, separator, gmt, name)
+ end
+
+ def addDateTimeMentry(format, date_sep, time_sep, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addDateTimeMentry',
+ format, date_sep, time_sep, gmt, name)
+ end
+
+ def addFixedPointMentry(count1, count2, comma=false, name=None)
+ if comma && comma != None
+ comma = '-comma'
+ else
+ comma = None
+ end
+ Tk.tk_call('::tablelist::addFixedPoingMentry', count1, count2, comma, name)
+ end
+
+ def addIPAddrMentry(name=None)
+ Tk.tk_call('::tablelist::addIPAddrMentry', name)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb
new file mode 100644
index 0000000..0a14584
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/tcllib/tablelist_tlie.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A multi-column listbox
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tablelist_tile', '4.2')
+TkPackage.require('tablelist_tile')
+
+unless defined? Tk::Tcllib::Tablelist_usingTile
+ Tk::Tcllib::Tablelist_usingTile = true
+end
+
+requrie 'tkextlib/tcllib/tablelist_core'
+
+module Tk
+ module Tcllib
+ class Tablelist
+ # commands related to tile Themems
+ def self.set_theme(theme)
+ Tk.tk_call('::tablelist::setTheme', theme)
+ end
+
+ def self.get_current_theme
+ Tk.tk_call('::tablelist::getCurrentTheme')
+ end
+
+ def self.get_theme_list
+ TkComm.simplelist(Tk.tk_call('::tablelist::getThemes'))
+ end
+ def self.set_theme_defaults
+ Tk.tk_call('::tablelist::setThemeDefaults')
+ end
+ end
+
+ Tablelist_Tile = Tablelist
+ TableList_Tile = Tablelist
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
new file mode 100644
index 0000000..2f6e4b4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
@@ -0,0 +1,314 @@
+#
+# tkextlib/tcllib/tkpiechart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create 2D or 3D pies with labels in Tcl canvases
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tkpiechart', '6.6')
+TkPackage.require('tkpiechart')
+
+module Tk
+ module Tcllib
+ module Tkpiechart
+ end
+ end
+end
+
+module Tk::Tcllib::Tkpiechart
+ PACKAGE_NAME = 'tkpiechart'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tkpiechart')
+ rescue
+ ''
+ end
+ end
+
+ module ConfigMethod
+ include TkConfigMethod
+
+ def __pathname
+ self.path + ';' + self.tag
+ end
+ private :__pathname
+
+ def __cget_cmd
+ ['::switched::cget', self.tag]
+ end
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ def __configinfo_struct
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>1, :current_value=>2}
+ end
+ private :__configinfo_struct
+
+ def __boolval_optkeys
+ super() << 'select' << 'autoupdate' << 'selectable'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'bordercolor' << 'textbackground' <<
+ 'widestvaluetext' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'colors'
+ end
+ private :__listval_optkeys
+ end
+
+ ####################################
+ class PieChartObj < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['titlefont']
+ end
+ private :__font_optkeys
+ end
+
+ ####################################
+ class Pie < TkcItem
+ include ConfigMethod
+
+ def create_self(x, y, width, height, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie',
+ @c, x, y, *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y)
+ end
+
+ @slice_tbl = {}
+
+ id = "pie(#{@tag_key})"
+
+ @tag = @tag_pie = TkcNamedTag(@c, id)
+ @tag_slices = TkcNamedTag(@c, "pieSlices(#{@tag_key})")
+
+ id
+ end
+ private :create_self
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def canvas
+ @c
+ end
+ def _entry_slice(slice)
+ @slice_tbl[slice.to_eval] = slice
+ end
+ def _delete_slice(slice)
+ @slice_tbl.delete(slice.to_eval)
+ end
+
+ def delete
+ tk_call_without_enc('::stooop::delete', @tag_key)
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ self
+ end
+
+ def new_slice(text=None)
+ Slice.new(self, text)
+ end
+
+ def delete_slice(slice)
+ unless slice.kind_of?(Slice)
+ unless (slice = @slice_tbl[slice])
+ return tk_call_without_enc('pie::deleteSlice', @tag_key, slice)
+ end
+ end
+ unless slice.kind_of?(Slice) && slice.pie == self
+ fail ArgumentError, "argument is not a slice of self"
+ end
+ slice.delete
+ end
+
+ def selected_slices
+ tk_split_simplelist(tk_call_without_enc('pie::selectedSlices',
+ @tag_key)).collect{|slice|
+ @slice_tbl[slice] || Slice.new(:no_create, self, slice)
+ }
+ end
+ end
+
+ ####################################
+ class Slice < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def initialize(pie, *args)
+ unless pie.kind_of?(Pie) && pie != :no_create
+ fail ArgumentError, "expects TkPiechart::Pie for 1st argument"
+ end
+
+ if pie == :no_create
+ @pie, @tag_key = args
+ else
+ text = args[0] || None
+ @pie = pie
+ @tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text)
+ end
+ @parent = @c = @pie.canvas
+ @path = @parent.path
+
+ @pie._entry_slice(self)
+
+ @id = "slices(#{@tag_key})"
+ @tag = TkcNamedTag.new(@pie.canvas, @id)
+
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ }
+ end
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def pie
+ @pie
+ end
+
+ def delete
+ tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key)
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ @pie._delete_slice(self)
+ self
+ end
+
+ def size(share, disp=None)
+ tk_call_without_enc('pie::sizeSlice',
+ @pie.tag_key, @tag_key, share, disp)
+ self
+ end
+
+ def label(text)
+ tk_call_without_enc('pie::labelSlice', @pie.tag_key, @tag_key, text)
+ self
+ end
+ end
+
+ ####################################
+ class BoxLabeler < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler')
+ end
+
+ id = "pieBoxLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class PeripheralLabeler < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['font', 'smallfont']
+ end
+ private :__font_optkeys
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new',
+ 'piePeripheralLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler')
+ end
+
+ id = "piePeripheralLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class Label < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(x, y, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height,
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height)
+ end
+
+ id = "canvasLabel(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb
new file mode 100644
index 0000000..6eae4eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/tcllib/toolbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * toolbar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::toolbar', '1.2')
+TkPackage.require('widget::toolbar')
+
+module Tk::Tcllib
+ module Widget
+ class Toolbar < TkWindow
+ PACKAGE_NAME = 'widget::toolbar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::toolbar')
+ rescue
+ ''
+ end
+ end
+ end
+
+ module ToolbarItemConfig
+ include TkItemConfigMethod
+ end
+ end
+end
+
+
+class Tk::Tcllib::Widget::ToolbarItem < TkObject
+ include TkTreatTagFont
+
+ ToolbarItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TTagID_TBL.mutex.synchronize{ TTagID_TBL.clear }
+ }
+
+ def ToolbarItem.id2obj(tbar, id)
+ tpath = tbar.path
+ ToolbarItemID_TBL.mutex.synchronize{
+ if ToolbarItemID_TBL[tpath]
+ ToolbarItemID_TBL[tpath][id]? ToolbarItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initaialize(parent, *args)
+ @parent = @t = parent
+ @tpath = parent.path
+
+ @path = @id = @t.tk_send('add', *args)
+ # A same id is rejected by the Tcl function.
+
+ ToolbarItemID_TBL.mutex.synchronize{
+ ToolbarItemID_TBL[@id] = self
+ ToolbarItemID_TBL[@tpath] = {} unless ToolbarItemID_TBL[@tpath]
+ ToolbarItemID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget_tkstring(option)
+ @t.itemcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.itemcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.itemcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.itemconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_itemconfiginfo(@id, key)
+ end
+
+ def delete
+ @t.delete(@id)
+ end
+
+ def itemid
+ @t.itemid(@id)
+ end
+
+ def remove
+ @t.remove(@id)
+ end
+ def remove_with_destroy
+ @t.remove_with_destroy(@id)
+ end
+end
+
+class Tk::Tcllib::Widget::Toolbar
+ include Tk::Tcllib::Widget::ToolbarItemConfig
+
+ TkCommandNames = ['::widget::toolbar'.freeze].freeze
+
+ def __destroy_hook__
+ Tk::Tcllib::Widget::ToolbarItem::ToolbarItemID_TBL.mutex.synchronize{
+ Tk::Tcllib::Widget::ToolbarItem::ToolbarItemID_TBL.delete(@path)
+ }
+ end
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send('getframe'))
+ end
+ alias get_frame getframe
+
+ def add(*args)
+ Tk::Tcllib::Widget::Toolbar.new(self, *args)
+ end
+
+ def itemid(item)
+ window(tk_send('itemid'))
+ end
+
+ def items(pattern)
+ tk_split_simplelist(tk_send('items', pattern)).map{|id|
+ Tk::Tcllib::Widget::ToolbarItem.id2obj(self, id)
+ }
+ end
+
+ def remove(*items)
+ tk_send('remove', *items)
+ self
+ end
+
+ def remove_with_destroy(*items)
+ tk_send('remove', '-destroy', *items)
+ self
+ end
+
+ def delete(*items)
+ tk_send('delete', *items)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb
new file mode 100644
index 0000000..070e63a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb
@@ -0,0 +1,104 @@
+#
+# tkextlib/tcllib/tooltip.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides tooltips, a small text message that is displayed when the
+# mouse hovers over a widget.
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tooltip', '1.1')
+TkPackage.require('tooltip')
+
+module Tk::Tcllib
+ module Tooltip
+ PACKAGE_NAME = 'tooltip'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tooltip')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Tooltip
+ extend TkCore
+
+ WidgetClassName = 'Tooltip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.database_classname
+ self::WidgetClassName
+ end
+ def self.database_class
+ WidgetClassNames[self::WidgetClassName]
+ end
+
+ def self.clear(glob_path_pat = None)
+ self.clear_glob(glob_path_pat)
+ end
+
+ def self.clear_glob(glob_path_pat)
+ tk_call_without_enc('::tooltip::tooltip', 'clear', glob_path_pat)
+ end
+
+ def self.clear_widgets(*args)
+ self.clear_glob("{#{args.collect{|w| _get_eval_string(w)}.join(',')}}")
+ end
+
+ def self.clear_children(*args)
+ self.clear_glob("{#{args.collect{|w| s = _get_eval_string(w); "#{s},#{s}.*"}.join(',')}}")
+ end
+
+ def self.delay(millisecs=None)
+ number(tk_call_without_enc('::tooltip::tooltip', 'delay', millisecs))
+ end
+ def self.delay=(millisecs)
+ self.delay(millisecs)
+ end
+
+ def self.fade?
+ bool(tk_call_without_enc('::tooltip::tooltip', 'fade'))
+ end
+ def self.fade(mode)
+ tk_call_without_enc('::tooltip::tooltip', 'fade', mode)
+ end
+
+ def self.disable
+ tk_call_without_enc('::tooltip::tooltip', 'disable')
+ false
+ end
+ def self.off
+ self.disable
+ end
+
+ def self.enable
+ tk_call_without_enc('::tooltip::tooltip', 'enable')
+ true
+ end
+ def self.on
+ self.enable
+ end
+
+ def self.register(widget, msg, keys=nil)
+ if keys.kind_of?(Hash)
+ args = hash_kv(keys) << msg
+ else
+ args = msg
+ end
+ tk_call('::tooltip::tooltip', widget.path, *args)
+ end
+
+ def self.erase(widget)
+ tk_call_without_enc('::tooltip::tooltip', widget.path, '')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb
new file mode 100644
index 0000000..3a71960
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb
@@ -0,0 +1,65 @@
+#
+# tkextlib/tcllib/validator.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides a unified validation API
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::validator', '0.1')
+TkPackage.require('widget::validator')
+
+module Tk::Tcllib
+ module Validator
+ PACKAGE_NAME = 'widget::validator'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::validator')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Validator
+ extend TkCore
+
+ def self.attach(widget, color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'attach', widget, color, cmd)
+ nil
+ end
+
+ def self.detach(widget)
+ tk_call_without_enc('::widget::validator', 'detach', widget)
+ nil
+ end
+
+ def self.validate(widget)
+ tk_call_without_enc('::widget::validator', 'validate', widget)
+ nil
+ end
+
+ def attach_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'attach', @path, color, cmd)
+ self
+ end
+
+ def detach_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'detach', @path)
+ self
+ end
+
+ def invoke_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'validate', @path)
+ self
+ end
+ alias validate_validator invoke_validator
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb
new file mode 100644
index 0000000..57fdf7a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb
@@ -0,0 +1,82 @@
+#
+# tkextlib/tcllib/widget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * megawidget package that uses snit as the object system (snidgets)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget', '3.0')
+TkPackage.require('widget')
+
+module Tk::Tcllib
+ module Widget
+ PACKAGE_NAME = 'widget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget')
+ rescue
+ ''
+ end
+ end
+
+ #--- followings may be private functions of tklib
+ def self.isa(compare_as, *args)
+ begin
+ return Tk.tk_call('::widget::isa', compare_as, *args)
+ rescue => e
+ if TkComm.bool(Tk.tk_call('info','command','::widget::isa')) ||
+ ! TkComm.bool(Tk.tk_call('info','command','::widget::validate'))
+ fail e
+ end
+ end
+ Tk.tk_call('::widget::validate', compare_as, *args)
+ end
+ def self.validate(compare_as, *args)
+ begin
+ return Tk.tk_call('::widget::validate', compare_as, *args)
+ rescue => e
+ if TkComm.bool(Tk.tk_call('info','command','::widget::validate')) ||
+ ! TkComm.bool(Tk.tk_call('info','command','::widget::isa'))
+ fail e
+ end
+ end
+ Tk.tk_call('::widget::isa', compare_as, *args)
+ end
+ end
+end
+
+module Tk::Tcllib::Widget
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ autoload :Calendar, 'tkextlib/tcllib/calendar'
+
+ autoload :Canvas_Sqmap, 'tkextlib/tcllib/canvas_sqmap'
+ autoload :Canvas_Zoom, 'tkextlib/tcllib/canvas_zoom'
+
+ autoload :Dialog, 'tkextlib/tcllib/dialog'
+
+ autoload :Panelframe, 'tkextlib/tcllib/panelframe'
+ autoload :PanelFrame, 'tkextlib/tcllib/panelframe'
+
+ autoload :Ruler, 'tkextlib/tcllib/ruler'
+
+ autoload :Screenruler, 'tkextlib/tcllib/screenruler'
+ autoload :ScreenRuler, 'tkextlib/tcllib/screenruler'
+
+ autoload :Scrolledwindow, 'tkextlib/tcllib/scrollwin'
+ autoload :ScrolledWindow, 'tkextlib/tcllib/scrollwin'
+
+ autoload :Superframe, 'tkextlib/tcllib/superframe'
+ autoload :SuperFrame, 'tkextlib/tcllib/superframe'
+
+ autoload :Toolbar, 'tkextlib/tcllib/toolbar'
+ autoload :ToolbarItem, 'tkextlib/tcllib/toolbar'
+end