mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/tk/lib/tk.rb: better operation for SIGINT when processing callbacks.
* ext/tk/lib/tk/msgcat.rb: ditto. * ext/tk/lib/tk/variable.rb: ditto. * ext/tk/lib/tk/timer.rb: ditto. * ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd() to define validatecommand methods easier git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									29c3cb6d20
								
							
						
					
					
						commit
						e55330c9c4
					
				
					 45 changed files with 1162 additions and 20 deletions
				
			
		
							
								
								
									
										12
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								ChangeLog
									
										
									
									
									
								
							|  | @ -1,3 +1,15 @@ | |||
| Sat Jul 10 04:21:56 2004  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | ||||
| 
 | ||||
| 	* ext/tk/lib/tk.rb: better operation for SIGINT when processing  | ||||
| 	  callbacks. | ||||
| 	* ext/tk/lib/tk/msgcat.rb: ditto. | ||||
| 	* ext/tk/lib/tk/variable.rb: ditto. | ||||
| 	* ext/tk/lib/tk/timer.rb: ditto. | ||||
| 
 | ||||
| 	* ext/tk/lib/tk/validation.rb (__def_validcmd):  add a module  | ||||
| 	  function of Tk::ValidateConfigure to define validatecommand  | ||||
| 	  methods easier | ||||
| 
 | ||||
| Fri Jul  9 22:18:59  Hirokazu Yamamoto  <ocean@m2.ccsnet.ne.jp> | ||||
| 
 | ||||
| 	* array.c, enum.c, pack.c: rdoc patch from Johan Holmberg | ||||
|  |  | |||
|  | @ -1,3 +1,19 @@ | |||
| 2004-07-10  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | ||||
| 
 | ||||
| 	* bug fix | ||||
| 
 | ||||
| 	* add more part of [incr Widget] support (about 65%? are complete) | ||||
| 
 | ||||
| 	* use Tk::ValidateConfigure.__def_validcmd() method | ||||
|           (new function to define validatecommand methods easier) | ||||
| 
 | ||||
| 	* tcllib.rb : avoid the loading trouble that almost all part of  | ||||
| 	  the extension is not available when some libraries are invalid.  | ||||
| 
 | ||||
| 2004-07-09  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | ||||
| 
 | ||||
| 	* add some part of [incr Widget] support (about 50%? are complete) | ||||
| 
 | ||||
| 2004-07-07  Hidetoshi NAGAI  <nagai@ai.kyutech.ac.jp> | ||||
| 
 | ||||
| 	* add [incr Tck], [incr Tk] support | ||||
|  |  | |||
|  | @ -1070,6 +1070,10 @@ module TkCore | |||
|   def TkCore.callback(*arg) | ||||
|     begin | ||||
|       TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) | ||||
|     rescue SystemExit | ||||
|       exit(0) | ||||
|     rescue Interrupt | ||||
|       exit!(1) | ||||
|     rescue Exception => e | ||||
|       begin | ||||
| 	msg = _toUTF8(e.class.inspect) + ': ' +  | ||||
|  |  | |||
|  | @ -2,13 +2,16 @@ | |||
| # tk/canvastag.rb - methods for treating canvas tags | ||||
| # | ||||
| require 'tk' | ||||
| require 'tk/canvas' | ||||
| require 'tk/tagfont' | ||||
| 
 | ||||
| module TkcTagAccess | ||||
|   include TkComm | ||||
|   include TkTreatTagFont | ||||
| end | ||||
| 
 | ||||
| require 'tk/canvas' | ||||
| 
 | ||||
| module TkcTagAccess | ||||
|   def addtag(tag) | ||||
|     @c.addtag(tag, 'with', @id) | ||||
|     self | ||||
|  |  | |||
|  | @ -57,6 +57,10 @@ class TkMsgCatalog < TkObject | |||
|     return src_str unless cmd       # no cmd -> return src-str (default action) | ||||
|     begin | ||||
|       cmd.call(locale, src_str) | ||||
|     rescue SystemExit | ||||
|       exit(0) | ||||
|     rescue Interrupt | ||||
|       exit!(1) | ||||
|     rescue Exception => e | ||||
|       begin | ||||
| 	msg = _toUTF8(e.class.inspect) + ': ' +  | ||||
|  |  | |||
|  | @ -61,11 +61,16 @@ class TkTimer | |||
|     @in_callback = true | ||||
|     begin | ||||
|       @return_value = @current_proc.call(self) | ||||
|     rescue SystemExit | ||||
|       exit(0) | ||||
|     rescue Interrupt | ||||
|       exit!(1) | ||||
|     rescue Exception => e | ||||
|       if @cancel_on_exception &&  | ||||
| 	  @cancel_on_exception.find{|exc| e.kind_of?(exc)} | ||||
| 	cancel | ||||
| 	@return_value = e | ||||
| 	@in_callback = false | ||||
| 	return e | ||||
|       else | ||||
| 	fail e | ||||
|  |  | |||
|  | @ -5,6 +5,29 @@ require 'tk' | |||
| 
 | ||||
| module Tk | ||||
|   module ValidateConfigure | ||||
|     def self.__def_validcmd(scope, klass, keys=nil) | ||||
|       keys = klass._config_keys unless keys | ||||
|       keys.each{|key| | ||||
| 	eval("def #{key}(*args, &b) | ||||
|                  __validcmd_call(#{klass.name}, '#{key}', *args, &b) | ||||
|               end", scope) | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     def __validcmd_call(klass, key, *args, &b) | ||||
|       return cget(key) if args.empty? && !b | ||||
| 
 | ||||
|       cmd = (b)? proc(&b) : args.shift | ||||
| 
 | ||||
|       if cmd.kind_of?(klass) | ||||
| 	configure(key, cmd) | ||||
|       elsif !args.empty? | ||||
| 	configure(key, [cmd, args]) | ||||
|       else | ||||
| 	configure(key, cmd) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     def __validation_class_list | ||||
|       # maybe need to override | ||||
|       [] | ||||
|  | @ -73,6 +96,29 @@ module Tk | |||
|   end | ||||
| 
 | ||||
|   module ItemValidateConfigure | ||||
|     def self.__def_validcmd(scope, klass, keys=nil) | ||||
|       keys = klass._config_keys unless keys | ||||
|       keys.each{|key| | ||||
| 	eval("def item_#{key}(id, *args, &b) | ||||
|                  __item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b) | ||||
|               end", scope) | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     def __item_validcmd_call(tagOrId, klass, key, *args, &b) | ||||
|       return itemcget(tagid(tagOrId), key) if args.empty? && !b | ||||
| 
 | ||||
|       cmd = (b)? proc(&b) : args.shift | ||||
| 
 | ||||
|       if cmd.kind_of?(klass) | ||||
| 	itemconfigure(tagid(tagOrId), key, cmd) | ||||
|       elsif !args.empty? | ||||
| 	itemconfigure(tagid(tagOrId), key, [cmd, args]) | ||||
|       else | ||||
| 	itemconfigure(tagid(tagOrId), key, cmd) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     def __item_validation_class_list(id) | ||||
|       # maybe need to override | ||||
|       [] | ||||
|  | @ -265,6 +311,9 @@ module TkValidation | |||
|     super << ValidateCmd | ||||
|   end | ||||
| 
 | ||||
|   Tk::ValidateConfigure.__def_validcmd(binding, ValidateCmd) | ||||
| 
 | ||||
| =begin | ||||
|   def validatecommand(cmd = Proc.new, args = nil) | ||||
|     if cmd.kind_of?(ValidateCmd) | ||||
|       configure('validatecommand', cmd) | ||||
|  | @ -274,8 +323,13 @@ module TkValidation | |||
|       configure('validatecommand', cmd) | ||||
|     end | ||||
|   end | ||||
|   alias vcmd validatecommand | ||||
| =end | ||||
| #  def validatecommand(*args, &b) | ||||
| #    __validcmd_call(ValidateCmd, 'validatecommand', *args, &b) | ||||
| #  end | ||||
| #  alias vcmd validatecommand | ||||
| 
 | ||||
| =begin | ||||
|   def invalidcommand(cmd = Proc.new, args = nil) | ||||
|     if cmd.kind_of?(ValidateCmd) | ||||
|       configure('invalidcommand', cmd) | ||||
|  | @ -285,5 +339,9 @@ module TkValidation | |||
|       configure('invalidcommand', cmd) | ||||
|     end | ||||
|   end | ||||
|   alias invcmd invalidcommand | ||||
| =end | ||||
| #  def invalidcommand(*args, &b) | ||||
| #    __validcmd_call(ValidateCmd, 'invalidcommand', *args, &b) | ||||
| #  end | ||||
| #  alias invcmd invalidcommand | ||||
| end | ||||
|  |  | |||
|  | @ -48,6 +48,10 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL') | |||
|       #_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op)) | ||||
|       begin | ||||
| 	_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2, op)) | ||||
|       rescue SystemExit | ||||
| 	exit(0) | ||||
|       rescue Interrupt | ||||
| 	exit!(1) | ||||
|       rescue Exception => e | ||||
| 	begin | ||||
| 	  msg = _toUTF8(e.class.inspect) + ': ' +  | ||||
|  |  | |||
|  | @ -1,6 +1,9 @@ | |||
| # | ||||
| # tk/winfo.rb : methods for winfo command | ||||
| # | ||||
| module TkWinfo | ||||
| end | ||||
| 
 | ||||
| require 'tk' | ||||
| 
 | ||||
| module TkWinfo | ||||
|  |  | |||
|  | @ -55,6 +55,7 @@ module Tk | |||
|       def component_path(name) | ||||
| 	window(tk_send('component', name)) | ||||
|       end | ||||
|       alias component_widget component_path | ||||
| 
 | ||||
|       def component_invoke(name, cmd, *args) | ||||
| 	window(tk_send('component', name, cmd, *args)) | ||||
|  |  | |||
|  | @ -50,8 +50,19 @@ module Tk | |||
|     autoload :Fileselectionbox,      'tkextlib/iwidgets/fileselectionbox' | ||||
|     autoload :Fileselectiondialog,   'tkextlib/iwidgets/fileselectiondialog' | ||||
|     autoload :Finddialog,            'tkextlib/iwidgets/finddialog' | ||||
|     autoload :Hierarchy,             'tkextlib/iwidgets/hierarchy' | ||||
|     autoload :Hyperhelp,             'tkextlib/iwidgets/hyperhelp' | ||||
|     autoload :Labeledframe,          'tkextlib/iwidgets/labeledframe' | ||||
|     autoload :Labeledwidget,         'tkextlib/iwidgets/labeledwidget' | ||||
|     autoload :Mainwindow,            'tkextlib/iwidgets/mainwindow' | ||||
|     autoload :Messagebox,            'tkextlib/iwidgets/messagebox' | ||||
|     autoload :Messagedialog,         'tkextlib/iwidgets/messagedialog' | ||||
|     autoload :Radiobox,              'tkextlib/iwidgets/radiobox' | ||||
|     autoload :Scrolledwidget,        'tkextlib/iwidgets/scrolledwidget' | ||||
|     autoload :Shell,                 'tkextlib/iwidgets/shell' | ||||
|     autoload :Timeentry,             'tkextlib/iwidgets/timeentry' | ||||
|     autoload :Timefield,             'tkextlib/iwidgets/timefield' | ||||
|     autoload :Toolbar,               'tkextlib/iwidgets/toolbar' | ||||
|     autoload :Watch,                 'tkextlib/iwidgets/watch' | ||||
|   end | ||||
| end | ||||
|  |  | |||
|  | @ -36,7 +36,8 @@ class Tk::Iwidgets::Buttonbox | |||
|     if tagOrId.kind_of?(Tk::Itk::Component) | ||||
|       tagOrId.name | ||||
|     else | ||||
|       _get_eval_string(tagOrId) | ||||
|       #_get_eval_string(tagOrId) | ||||
|       tagOrId | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
|  | @ -48,6 +48,8 @@ class Tk::Iwidgets::Calendar | |||
|     super << CalendarCommand | ||||
|   end | ||||
| 
 | ||||
|   Tk::ValidateConfigure.__def_validcmd(binding, CalendarCommand) | ||||
| =begin | ||||
|   def command(cmd = Proc.new, args = nil) | ||||
|     if cmd.kind_of?(CalendarCommand) | ||||
|       configure('command', cmd) | ||||
|  | @ -57,6 +59,7 @@ class Tk::Iwidgets::Calendar | |||
|       configure('command', cmd) | ||||
|     end | ||||
|   end | ||||
| =end | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|  |  | |||
|  | @ -36,7 +36,8 @@ class Tk::Iwidgets::Checkbox | |||
|     if tagOrId.kind_of?(Tk::Itk::Component) | ||||
|       tagOrId.name | ||||
|     else | ||||
|       _get_eval_string(tagOrId) | ||||
|       #_get_eval_string(tagOrId) | ||||
|       tagOrId | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
|  | @ -82,7 +82,7 @@ class Tk::Iwidgets::Combobox | |||
|   def sort(*params, &b) | ||||
|     # see 'lsort' man page about params | ||||
|     if b | ||||
|       tk_call(@path, 'sort', *params, -'command', proc(&b)) | ||||
|       tk_call(@path, 'sort', '-command', proc(&b), *params) | ||||
|     else | ||||
|       tk_call(@path, 'sort', *params) | ||||
|     end | ||||
|  | @ -91,6 +91,7 @@ class Tk::Iwidgets::Combobox | |||
|   def sort_ascending | ||||
|     tk_call(@path, 'sort', 'ascending') | ||||
|     self | ||||
|   end | ||||
|   def sort_descending | ||||
|     tk_call(@path, 'sort', 'descending') | ||||
|     self | ||||
|  |  | |||
|  | @ -30,8 +30,9 @@ class Tk::Iwidgets::Datefield | |||
|   def valid? | ||||
|     bool(tk_call(@path, 'isvalid')) | ||||
|   end | ||||
|   alias isvalid? valid? | ||||
| 
 | ||||
|   def show(date) | ||||
|   def show(date=None) | ||||
|     tk_call(@path, 'show', date) | ||||
|     self | ||||
|   end | ||||
|  |  | |||
|  | @ -36,7 +36,8 @@ class Tk::Iwidgets::Dialogshell | |||
|     if tagOrId.kind_of?(Tk::Itk::Component) | ||||
|       tagOrId.name | ||||
|     else | ||||
|       _get_eval_string(tagOrId) | ||||
|       #_get_eval_string(tagOrId) | ||||
|       tagOrId | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
|  | @ -49,6 +49,8 @@ class Tk::Iwidgets::Entryfield | |||
|     super << EntryfieldValidate | ||||
|   end | ||||
| 
 | ||||
|   Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate) | ||||
| =begin | ||||
|   def validate(cmd = Proc.new, args = nil) | ||||
|     if cmd.kind_of?(ValidateCmd) | ||||
|       configure('validate', cmd) | ||||
|  | @ -68,6 +70,7 @@ class Tk::Iwidgets::Entryfield | |||
|       configure('invalid', cmd) | ||||
|     end | ||||
|   end | ||||
| =end | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										294
									
								
								ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										294
									
								
								ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,294 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/hierarchy.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tk/text' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Hierarchy < Tk::Iwidgets::Scrolledwidget | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Hierarchy | ||||
|   ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze | ||||
|   include TkTextTagConfig | ||||
| 
 | ||||
|   TkCommandNames = ['::iwidgets::hierarchy'.freeze].freeze | ||||
|   WidgetClassName = 'Hierarchy'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   include Tk::ValidateConfigure | ||||
| 
 | ||||
|   class QueryCommand < TkValidateCommand | ||||
|     class ValidateArgs < TkUtil::CallbackSubst | ||||
|       KEY_TBL  = [ [?n, ?s, :node], nil ] | ||||
|       PROC_TBL = [ [?s, TkComm.method(:string) ], nil ] | ||||
|       _setup_subst_table(KEY_TBL, PROC_TBL); | ||||
| 
 | ||||
|       def self.ret_val(val) | ||||
| 	val | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     def self._config_keys | ||||
|       # array of config-option key (string or symbol) | ||||
|       ['querycommand'] | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   class IndicatorCommand < TkValidateCommand | ||||
|     class ValidateArgs < TkUtil::CallbackSubst | ||||
|       KEY_TBL  = [  | ||||
| 	[ ?n, ?s, :node ],  | ||||
| 	[ ?s, ?b, :status ],  | ||||
| 	nil | ||||
|       ] | ||||
| 
 | ||||
|       PROC_TBL = [  | ||||
| 	[ ?s, TkComm.method(:string) ],  | ||||
| 	[ ?b, TkComm.method(:bool) ],  | ||||
| 	nil | ||||
|       ] | ||||
| 
 | ||||
|       _setup_subst_table(KEY_TBL, PROC_TBL); | ||||
| 
 | ||||
|       def self.ret_val(val) | ||||
| 	val | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     def self._config_keys | ||||
|       # array of config-option key (string or symbol) | ||||
|       ['iconcommand', 'icondblcommand', 'imagedblcommand'] | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   class IconCommand < TkValidateCommand | ||||
|     class ValidateArgs < TkUtil::CallbackSubst | ||||
|       KEY_TBL  = [  | ||||
| 	[ ?n, ?s, :node ],  | ||||
| 	[ ?i, ?s, :icon ],  | ||||
| 	nil | ||||
|       ] | ||||
|       PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ] | ||||
|       _setup_subst_table(KEY_TBL, PROC_TBL); | ||||
| 
 | ||||
|       def self.ret_val(val) | ||||
| 	val | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     def self._config_keys | ||||
|       # array of config-option key (string or symbol) | ||||
|       ['dblclickcommand', 'imagecommand', 'selectcommand'] | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def __validation_class_list | ||||
|     super << QueryCommand << IndicatorCommand << IconCommand | ||||
|   end | ||||
| 
 | ||||
|   Tk::ValidateConfigure.__def_validcmd(binding, QueryCommand) | ||||
|   Tk::ValidateConfigure.__def_validcmd(binding, IndicatorCommand) | ||||
|   Tk::ValidateConfigure.__def_validcmd(binding, IconCommand) | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   def clear | ||||
|     tk_call(@path, 'clear') | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def collapse(node) | ||||
|     tk_call(@path, 'collapse') | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def current | ||||
|     tk_call(@path, 'current') | ||||
|   end | ||||
| 
 | ||||
|   def draw(mode=None) | ||||
|     case mode | ||||
|     when None | ||||
|       # do nothing | ||||
|     when 'now', :now | ||||
|       mode = '-now' | ||||
|     when 'eventually', :eventually | ||||
|       mode = '-eventually' | ||||
|     when String, Symbol | ||||
|       mode = mode.to_s | ||||
|       mode = '-' << mode if mode[0] != ?- | ||||
|     end | ||||
|     tk_call(@path, 'draw', mode) | ||||
|   end | ||||
| 
 | ||||
|   def expand(node) | ||||
|     tk_call(@path, 'expand', node) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def expanded?(node) | ||||
|     bool(tk_call(@path, 'expanded', node)) | ||||
|   end | ||||
| 
 | ||||
|   def exp_state | ||||
|     list(tk_call(@path, 'expState')) | ||||
|   end | ||||
|   alias expand_state  exp_state | ||||
|   alias expanded_list exp_state | ||||
| 
 | ||||
|   def mark_clear | ||||
|     tk_call(@path, 'mark', 'clear') | ||||
|     self | ||||
|   end | ||||
|   def mark_add(*nodes) | ||||
|     tk_call(@path, 'mark', 'add', *nodes) | ||||
|     self | ||||
|   end | ||||
|   def mark_remove(*nodes) | ||||
|     tk_call(@path, 'mark', 'remove', *nodes) | ||||
|     self | ||||
|   end | ||||
|   def mark_get | ||||
|     list(tk_call(@path, 'mark', 'get')) | ||||
|   end | ||||
| 
 | ||||
|   def refresh(node) | ||||
|     tk_call(@path, 'refresh', node) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def prune(node) | ||||
|     tk_call(@path, 'prune', node) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def selection_clear | ||||
|     tk_call(@path, 'selection', 'clear') | ||||
|     self | ||||
|   end | ||||
|   def selection_add(*nodes) | ||||
|     tk_call(@path, 'selection', 'add', *nodes) | ||||
|     self | ||||
|   end | ||||
|   def selection_remove(*nodes) | ||||
|     tk_call(@path, 'selection', 'remove', *nodes) | ||||
|     self | ||||
|   end | ||||
|   def selection_get | ||||
|     list(tk_call(@path, 'selection', 'get')) | ||||
|   end | ||||
| 
 | ||||
|   def toggle(node) | ||||
|     tk_call(@path, 'toggle', node) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   # based on TkText widget | ||||
| 
 | ||||
|   def bbox(index) | ||||
|     list(tk_send_without_enc('bbox', _get_eval_enc_str(index))) | ||||
|   end | ||||
| 
 | ||||
|   def compare(idx1, op, idx2) | ||||
|     bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),  | ||||
| 			     op, _get_eval_enc_str(idx2))) | ||||
|   end | ||||
| 
 | ||||
|   def debug | ||||
|     bool(tk_send_without_enc('debug')) | ||||
|   end | ||||
|   def debug=(boolean) | ||||
|     tk_send_without_enc('debug', boolean) | ||||
|     #self | ||||
|     boolean | ||||
|   end | ||||
| 
 | ||||
|   def delete(first, last=None) | ||||
|     tk_send_without_enc('delete', first, last) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def dlineinfo(index) | ||||
|     list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index))) | ||||
|   end | ||||
| 
 | ||||
|   def get(*index) | ||||
|     _fromUTF8(tk_send_without_enc('get', *index)) | ||||
|   end | ||||
| 
 | ||||
|   def index(index) | ||||
|     tk_send_without_enc('index', _get_eval_enc_str(index)) | ||||
|   end | ||||
| 
 | ||||
|   def insert(index, chars, *tags) | ||||
|     if tags[0].kind_of? Array | ||||
|       # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ... | ||||
|       args = [chars] | ||||
|       while tags.size > 0 | ||||
| 	args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ')  # taglist | ||||
| 	args << tags.shift if tags.size > 0                           # chars | ||||
|       end | ||||
|       super index, *args | ||||
|     else | ||||
|       # single chars-taglist argument :: str, tag, tag, ... | ||||
|       if tags.size == 0 | ||||
| 	super index, chars | ||||
|       else | ||||
| 	super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def scan_mark(x, y) | ||||
|     tk_send_without_enc('scan', 'mark', x, y) | ||||
|     self | ||||
|   end | ||||
|   def scan_dragto(x, y) | ||||
|     tk_send_without_enc('scan', 'dragto', x, y) | ||||
|     self | ||||
|   end | ||||
|   def see(index) | ||||
|     tk_send_without_enc('see', index) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   # based on tk/scrollable.rb | ||||
|   def xview(*index) | ||||
|     if index.size == 0 | ||||
|       list(tk_send_without_enc('xview')) | ||||
|     else | ||||
|       tk_send_without_enc('xview', *index) | ||||
|       self | ||||
|     end | ||||
|   end | ||||
|   def xview_moveto(*index) | ||||
|     xview('moveto', *index) | ||||
|   end | ||||
|   def xview_scroll(*index) | ||||
|     xview('scroll', *index) | ||||
|   end | ||||
| 
 | ||||
|   def yview(*index) | ||||
|     if index.size == 0 | ||||
|       list(tk_send_without_enc('yview')) | ||||
|     else | ||||
|       tk_send_without_enc('yview', *index) | ||||
|       self | ||||
|     end | ||||
|   end | ||||
|   def yview_moveto(*index) | ||||
|     yview('moveto', *index) | ||||
|   end | ||||
|   def yview_scroll(*index) | ||||
|     yview('scroll', *index) | ||||
|   end | ||||
| end | ||||
							
								
								
									
										40
									
								
								ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,40 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/hyperhelp.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Hyperhelp < Tk::Iwidgets::Shell | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Hyperhelp | ||||
|   TkCommandNames = ['::iwidgets::hyperhelp'.freeze].freeze | ||||
|   WidgetClassName = 'Hyperhelp'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   def show_topic(topic) | ||||
|     tk_call(@path, 'showtopic', topic) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def follow_link(href) | ||||
|     tk_call(@path, 'followlink', href) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def forward | ||||
|     tk_call(@path, 'forward') | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def back | ||||
|     tk_call(@path, 'back') | ||||
|     self | ||||
|   end | ||||
| end | ||||
							
								
								
									
										52
									
								
								ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,52 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/mainwindow.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Mainwindow < Tk::Iwidgets::Shell | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Mainwindow | ||||
|   TkCommandNames = ['::iwidgets::mainwindow'.freeze].freeze | ||||
|   WidgetClassName = 'Mainwindow'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   def child_site | ||||
|     window(tk_call(@path, 'childsite')) | ||||
|   end | ||||
| 
 | ||||
|   def menubar(*args) | ||||
|     unless args.empty? | ||||
|       tk_call(@path, 'menubar', *args) | ||||
|     end | ||||
|     window(tk_call(@path, 'menubar')) | ||||
|   end | ||||
| 
 | ||||
|   def mousebar(*args) | ||||
|     unless args.empty? | ||||
|       tk_call(@path, 'mousebar', *args) | ||||
|     end | ||||
|     window(tk_call(@path, 'mousebar')) | ||||
|   end | ||||
| 
 | ||||
|   def msgd(*args) | ||||
|     unless args.empty? | ||||
|       tk_call(@path, 'msgd', *args) | ||||
|     end | ||||
|     window(tk_call(@path, 'msgd')) | ||||
|   end | ||||
| 
 | ||||
|   def toolbar(*args) | ||||
|     unless args.empty? | ||||
|       tk_call(@path, 'toolbar', *args) | ||||
|     end | ||||
|     window(tk_call(@path, 'toolbar')) | ||||
|   end | ||||
| end | ||||
							
								
								
									
										81
									
								
								ext/tk/lib/tkextlib/iwidgets/messagebox.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								ext/tk/lib/tkextlib/iwidgets/messagebox.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,81 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/messagebox.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Messagebox < Tk::Iwidgets::Scrolledwidget | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Messagebox | ||||
|   TkCommandNames = ['::iwidgets::messagebox'.freeze].freeze | ||||
|   WidgetClassName = 'Messagebox'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   include TkItemConfigMethod | ||||
| 
 | ||||
|   def __item_cget_cmd(id) | ||||
|     [self.path, 'type', 'cget', id] | ||||
|   end | ||||
|   private :__item_cget_cmd | ||||
| 
 | ||||
|   def __item_config_cmd(id) | ||||
|     [self.path, 'type', 'configure', id] | ||||
|   end | ||||
|   private :__item_config_cmd | ||||
| 
 | ||||
|   def tagid(tagOrId) | ||||
|     if tagOrId.kind_of?(Tk::Itk::Component) | ||||
|       tagOrId.name | ||||
|     else | ||||
|       #_get_eval_string(tagOrId) | ||||
|       tagOrId | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   alias type_cget itemcget | ||||
|   alias type_configure itemconfigure | ||||
|   alias type_configinfo itemconfiginfo | ||||
|   alias current_type_configinfo current_itemconfiginfo | ||||
| 
 | ||||
|   private :itemcget, :itemconfigure | ||||
|   private :itemconfiginfo, :current_itemconfiginfo | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   def type_add(tag=nil, keys={}) | ||||
|     if tag.kind_of?(Hash) | ||||
|       keys = tag | ||||
|       tag = nil | ||||
|     end | ||||
|     unless tag | ||||
|       tag = Tk::Itk::Component.new(self) | ||||
|     end | ||||
|     tk_call(@path, 'type', 'add', tagid(tag), *hash_kv(keys)) | ||||
|     tag | ||||
|   end | ||||
| 
 | ||||
|   def clear | ||||
|     tk_call(@path, 'clear') | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def export(file) | ||||
|     tk_call(@path, 'export', file) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def issue(string, type=None, *args) | ||||
|     tk_call(@path, 'issue', string, tagid(type), *args) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
| end | ||||
							
								
								
									
										20
									
								
								ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/messagedialog.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Messagedialog < Tk::Iwidgets::Dialog | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Messagedialog | ||||
|   TkCommandNames = ['::iwidgets::messagedialog'.freeze].freeze | ||||
|   WidgetClassName = 'Messagedialog'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| end | ||||
							
								
								
									
										107
									
								
								ext/tk/lib/tkextlib/iwidgets/radiobox.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								ext/tk/lib/tkextlib/iwidgets/radiobox.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,107 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/radiobox.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Radiobox < Tk::Iwidgets::Labeledframe | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Radiobox | ||||
|   TkCommandNames = ['::iwidgets::radiobox'.freeze].freeze | ||||
|   WidgetClassName = 'Radiobox'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   include TkItemConfigMethod | ||||
| 
 | ||||
|   def __item_cget_cmd(id) | ||||
|     [self.path, 'buttoncget', id] | ||||
|   end | ||||
|   private :__item_cget_cmd | ||||
| 
 | ||||
|   def __item_config_cmd(id) | ||||
|     [self.path, 'buttonconfigure', id] | ||||
|   end | ||||
|   private :__item_config_cmd | ||||
| 
 | ||||
|   def tagid(tagOrId) | ||||
|     if tagOrId.kind_of?(Tk::Itk::Component) | ||||
|       tagOrId.name | ||||
|     else | ||||
|       #_get_eval_string(tagOrId) | ||||
|       tagOrId | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   alias buttoncget itemcget | ||||
|   alias buttonconfigure itemconfigure | ||||
|   alias buttonconfiginfo itemconfiginfo | ||||
|   alias current_buttonconfiginfo current_itemconfiginfo | ||||
| 
 | ||||
|   private :itemcget, :itemconfigure | ||||
|   private :itemconfiginfo, :current_itemconfiginfo | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   def add(tag=nil, keys={}) | ||||
|     if tag.kind_of?(Hash) | ||||
|       keys = tag | ||||
|       tag = nil | ||||
|     end | ||||
|     unless tag | ||||
|       tag = Tk::Itk::Component.new(self) | ||||
|     end | ||||
|     tk_call(@path, 'add', tagid(tag), *hash_kv(keys)) | ||||
|     tag | ||||
|   end | ||||
| 
 | ||||
|   def delete(idx) | ||||
|     tk_call(@path, 'delete', index(idx)) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def deselect(idx) | ||||
|     tk_call(@path, 'deselect', index(idx)) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def flash(idx) | ||||
|     tk_call(@path, 'flash', index(idx)) | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def get(idx) | ||||
|     simplelist(tk_call(@path, 'get', index(idx))).collect{|id| | ||||
|       Tk::Itk::Component.id2obj(id) | ||||
|     } | ||||
|   end | ||||
| 
 | ||||
|   def index(idx) | ||||
|     number(tk_call(@path, 'index', tagid(idx))) | ||||
|   end | ||||
| 
 | ||||
|   def insert(idx, tag=nil, keys={}) | ||||
|     if tag.kind_of?(Hash) | ||||
|       keys = tag | ||||
|       tag = nil | ||||
|     end | ||||
|     unless tag | ||||
|       tag = Tk::Itk::Component.new(self) | ||||
|     end | ||||
|     tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)) | ||||
|     tag | ||||
|   end | ||||
| 
 | ||||
|   def select(idx) | ||||
|     tk_call(@path, 'select', index(idx)) | ||||
|     self | ||||
|   end | ||||
| end | ||||
							
								
								
									
										20
									
								
								ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/scrolledwidget.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Scrolledwidget < Tk::Iwidgets::Labeledwidget | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Scrolledwidget | ||||
|   TkCommandNames = ['::iwidgets::scrolledwidget'.freeze].freeze | ||||
|   WidgetClassName = 'Scrolledwidget'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| end | ||||
							
								
								
									
										20
									
								
								ext/tk/lib/tkextlib/iwidgets/timeentry.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ext/tk/lib/tkextlib/iwidgets/timeentry.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/timeentry.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Timeentry < Tk::Iwidgets::Timefield | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Timeentry | ||||
|   TkCommandNames = ['::iwidgets::timeentry'.freeze].freeze | ||||
|   WidgetClassName = 'Timeentry'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| end | ||||
							
								
								
									
										43
									
								
								ext/tk/lib/tkextlib/iwidgets/timefield.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								ext/tk/lib/tkextlib/iwidgets/timefield.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/timefield.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class  Timefield < Tk::Iwidgets::Labeledwidget | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Timefield | ||||
|   TkCommandNames = ['::iwidgets::timefield'.freeze].freeze | ||||
|   WidgetClassName = 'Timefield'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   def get_string | ||||
|     tk_call(@path, 'get', '-string') | ||||
|   end | ||||
|   alias get get_string | ||||
| 
 | ||||
|   def get_clicks | ||||
|     number(tk_call(@path, 'get', '-clicks')) | ||||
|   end | ||||
| 
 | ||||
|   def valid? | ||||
|     bool(tk_call(@path, 'isvalid')) | ||||
|   end | ||||
|   alias isvalid? valid? | ||||
| 
 | ||||
|   def show(time=None) | ||||
|     tk_call(@path, 'show', time) | ||||
|     self | ||||
|   end | ||||
|   def show_now | ||||
|     tk_call(@path, 'show', 'now') | ||||
|     self | ||||
|   end | ||||
| end | ||||
							
								
								
									
										86
									
								
								ext/tk/lib/tkextlib/iwidgets/toolbar.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								ext/tk/lib/tkextlib/iwidgets/toolbar.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,86 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/toolbar.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Toolbar < Tk::Itk::Widget | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Toolbar | ||||
|   TkCommandNames = ['::iwidgets::toolbar'.freeze].freeze | ||||
|   WidgetClassName = 'Toolbar'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   include TkItemConfigMethod | ||||
| 
 | ||||
|   def tagid(tagOrId) | ||||
|     if tagOrId.kind_of?(Tk::Itk::Component) | ||||
|       tagOrId.name | ||||
|     else | ||||
|       #_get_eval_string(tagOrId) | ||||
|       tagOrId | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   #################################### | ||||
| 
 | ||||
|   def add(type, tag=nil, keys={}) | ||||
|     if tag.kind_of?(Hash) | ||||
|       keys = tag | ||||
|       tag = nil | ||||
|     end | ||||
|     unless tag | ||||
|       tag = Tk::Itk::Component.new(self) | ||||
|     end | ||||
|     tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys)) | ||||
|     tag | ||||
|   end | ||||
| 
 | ||||
|   def delete(idx1, idx2=nil) | ||||
|     if idx2 | ||||
|       tk_call(@path, 'delete', index(idx1), index(idx2)) | ||||
|     else | ||||
|       tk_call(@path, 'delete', index(idx1)) | ||||
|     end | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def index(idx) | ||||
|     number(tk_call(@path, 'index', tagid(idx))) | ||||
|   end | ||||
| 
 | ||||
|   def insert(idx, type, tag=nil, keys={}) | ||||
|     if tag.kind_of?(Hash) | ||||
|       keys = tag | ||||
|       tag = nil | ||||
|     end | ||||
|     unless tag | ||||
|       tag = Tk::Itk::Component.new(self) | ||||
|     end | ||||
|     tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys)) | ||||
|     tag | ||||
|   end | ||||
| 
 | ||||
|   def invoke(idx=nil) | ||||
|     if idx | ||||
|       tk_call(@path, 'invoke', index(idx)) | ||||
|     else | ||||
|       tk_call(@path, 'invoke') | ||||
|     end | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def show(idx) | ||||
|     tk_call(@path, 'show', index(idx)) | ||||
|     self | ||||
|   end | ||||
| end | ||||
							
								
								
									
										45
									
								
								ext/tk/lib/tkextlib/iwidgets/watch.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								ext/tk/lib/tkextlib/iwidgets/watch.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| # | ||||
| #  tkextlib/iwidgets/watch.rb | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| 
 | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets.rb' | ||||
| 
 | ||||
| module Tk | ||||
|   module Iwidgets | ||||
|     class Watch < Tk::Itk::Widget | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| class Tk::Iwidgets::Watch | ||||
|   TkCommandNames = ['::iwidgets::watch'.freeze].freeze | ||||
|   WidgetClassName = 'Watch'.freeze | ||||
|   WidgetClassNames[WidgetClassName] = self | ||||
| 
 | ||||
|   def get_string | ||||
|     tk_call(@path, 'get', '-string') | ||||
|   end | ||||
|   alias get get_string | ||||
| 
 | ||||
|   def get_clicks | ||||
|     number(tk_call(@path, 'get', '-clicks')) | ||||
|   end | ||||
| 
 | ||||
|   def show(time=None) | ||||
|     tk_call(@path, 'show', time) | ||||
|     self | ||||
|   end | ||||
|   def show_now | ||||
|     tk_call(@path, 'show', 'now') | ||||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def watch(*args) | ||||
|     unless args.empty? | ||||
|       tk_call(@path, 'watch', *args) | ||||
|     end | ||||
|     component_path('canvas') | ||||
|   end | ||||
| end | ||||
|  | @ -11,15 +11,31 @@ require 'tkextlib/setup.rb' | |||
| # call setup script | ||||
| require 'tkextlib/tcllib/setup.rb' | ||||
| 
 | ||||
| err = '' | ||||
| 
 | ||||
| # package:: autoscroll | ||||
| require 'tkextlib/tcllib/autoscroll' | ||||
| target = 'tkextlib/tcllib/autoscroll' | ||||
| begin | ||||
|   require target | ||||
| rescue => e | ||||
|   err << "\n  ['" << target << "'] "  << e.class.name << ' : ' << e.message | ||||
| end | ||||
| 
 | ||||
| # package:: cursor | ||||
| require 'tkextlib/tcllib/cursor' | ||||
| target = 'tkextlib/tcllib/cursor' | ||||
| begin | ||||
|   require target | ||||
| rescue => e | ||||
|   err << "\n  ['" << target << "'] "  << e.class.name << ' : ' << e.message | ||||
| end | ||||
| 
 | ||||
| # package:: style | ||||
| require 'tkextlib/tcllib/style' | ||||
| 
 | ||||
| target = 'tkextlib/tcllib/style' | ||||
| begin | ||||
|   require target | ||||
| rescue => e | ||||
|   err << "\n  ['" << target << "'] "  << e.class.name << ' : ' << e.message | ||||
| end | ||||
| 
 | ||||
| # autoload | ||||
| module Tk | ||||
|  | @ -41,3 +57,8 @@ module Tk | |||
|     autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart' | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| unless err.empty? | ||||
|   warn("Warning: some sub-packages are failed to require : " + err) | ||||
| end | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,9 +28,6 @@ require 'tk' | |||
| require 'tk/scrollbar' | ||||
| require 'tkextlib/tcllib.rb' | ||||
| 
 | ||||
| # TkPackage.require('autoscroll', '1.0') | ||||
| TkPackage.require('autoscroll') | ||||
| 
 | ||||
| module Tk | ||||
|   module Tcllib | ||||
|     module Autoscroll | ||||
|  | @ -43,7 +40,12 @@ module Tk | |||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
| 
 | ||||
| # TkPackage.require('autoscroll', '1.0') | ||||
| TkPackage.require('autoscroll') | ||||
| 
 | ||||
| module Tk | ||||
|   module Scrollable | ||||
|     def autoscroll(mode = nil) | ||||
|       case mode | ||||
|  |  | |||
|  | @ -137,7 +137,7 @@ class Tk::Tcllib::CText | |||
|     self | ||||
|   end | ||||
| 
 | ||||
|   def modified(mode) | ||||
|   def modified?(mode) | ||||
|     bool(tk_call('ctext::modified', @path, mode)) | ||||
|   end | ||||
| end | ||||
|  |  | |||
|  | @ -542,6 +542,8 @@ class Tk::TreeCtrl_Widget | |||
|   alias item_is_open    item_isopen | ||||
|   alias item_isopen?    item_isopen | ||||
|   alias item_is_open?   item_isopen | ||||
|   alias item_isopened?  item_isopen | ||||
|   alias item_is_opened? item_isopen | ||||
| 
 | ||||
|   def item_lastchild(parent, child=nil) | ||||
|     if child | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| #  ::vu::pie widget | ||||
| #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) | ||||
| # | ||||
| require 'tk' | ||||
| 
 | ||||
| # create module/class | ||||
| module Tk | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
| #  a standard spinbox (<= 8.3) | ||||
| #  This is the same as the 8.4 core spinbox widget. | ||||
| # | ||||
| require 'tk' | ||||
| 
 | ||||
| if (Tk::TK_MAJOR_VERSION < 8 ||  | ||||
|     (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION < 4)) | ||||
|  | @ -14,4 +15,8 @@ if (Tk::TK_MAJOR_VERSION < 8 || | |||
|   Tk.tk_call('namespace', 'import', '::vu::spinbox') | ||||
| end | ||||
| 
 | ||||
| Tk::Vu::Spinbox = TkSpinbox | ||||
| module Tk | ||||
|   module Vu | ||||
|     Spinbox = TkSpinbox | ||||
|   end | ||||
| end | ||||
|  |  | |||
							
								
								
									
										25
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| def get_files(file) | ||||
|   dir = (file.empty?)? ENV['HOME'] : file | ||||
|   Dir.chdir(dir) rescue return '' | ||||
|   rlist = [] | ||||
|   Dir['*'].sort.each{|f| rlist << File.join(dir, f) } | ||||
|   rlist | ||||
| end | ||||
| 
 | ||||
| Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{|arg| get_files(arg.node)},  | ||||
| 			    :visibleitems=>'30x15',  | ||||
| 			    :labeltext=>ENV['HOME']).pack(:side=>:left,  | ||||
| 							  :expand=>true,  | ||||
| 							  :fill=>:both) | ||||
| 
 | ||||
| # Tk::Iwidgets::Hierarchy.new(:querycommand=>[proc{|n| get_files(n)}, '%n'],  | ||||
| # 			    :visibleitems=>'30x15',  | ||||
| # 			    :labeltext=>ENV['HOME']).pack(:side=>:left,  | ||||
| # 							  :expand=>true,  | ||||
| # 							  :fill=>:both) | ||||
| 
 | ||||
| Tk.mainloop | ||||
							
								
								
									
										14
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| mainloop = Thread.new{Tk.mainloop} | ||||
| 
 | ||||
| dir  = '/usr/local/ActiveTcl/demos/IWidgets/html/' | ||||
| href = [ 'hyperhelp.n', 'buttonbox.n', 'calendar.n' ] | ||||
| 
 | ||||
| hh = Tk::Iwidgets::Hyperhelp.new(:topics=>href, :helpdir=>dir) | ||||
| hh.show_topic('hyperhelp.n') | ||||
| hh.activate | ||||
| 
 | ||||
| mainloop.join | ||||
							
								
								
									
										19
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,  | ||||
| 				  :labeltext=>'Messages', :labelpos=>:n,  | ||||
| 				  :height=>120, :width=>550,  | ||||
| 				  :savedir=>'/tmp', :textbackground=>'#d9d9d9') | ||||
| mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true) | ||||
| 
 | ||||
| mb.type_add('ERROR', :background=>'red', :foreground=>'white', :bell=>true) | ||||
| mb.type_add('WARNING', :background=>'yellow', :foreground=>'black') | ||||
| mb.type_add('INFO', :background=>'white', :foreground=>'black') | ||||
| 
 | ||||
| mb.issue('This is an error message in red with a beep', 'ERROR') | ||||
| mb.issue('This warning message in yellow', 'WARNING') | ||||
| mb.issue('This is an informational message', 'INFO') | ||||
| 
 | ||||
| Tk.mainloop | ||||
							
								
								
									
										19
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,  | ||||
| 				  :labeltext=>'Messages', :labelpos=>:n,  | ||||
| 				  :height=>120, :width=>550,  | ||||
| 				  :savedir=>'/tmp', :textbackground=>'#d9d9d9') | ||||
| mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true) | ||||
| 
 | ||||
| error   = mb.type_add(:background=>'red', :foreground=>'white', :bell=>true) | ||||
| warning = mb.type_add(:background=>'yellow', :foreground=>'black') | ||||
| info    = mb.type_add(:background=>'white', :foreground=>'black') | ||||
| 
 | ||||
| mb.issue('This is an error message in red with a beep', error) | ||||
| mb.issue('This warning message in yellow', warning) | ||||
| mb.issue('This is an informational message', info) | ||||
| 
 | ||||
| Tk.mainloop | ||||
							
								
								
									
										44
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,44 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| mainloop = Thread.new{Tk.mainloop} | ||||
| 
 | ||||
| # | ||||
| # Standard question message dialog used for confirmation. | ||||
| # | ||||
| md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog',  | ||||
| 				     :text=>'Are you sure ? ',  | ||||
| 				     :bitmap=>'questhead', :modality=>:global) | ||||
| 
 | ||||
| md.buttonconfigure('OK', :text=>'Yes') | ||||
| md.buttonconfigure('Cancel', :text=>'No') | ||||
| 
 | ||||
| if TkComm.bool(md.activate) | ||||
|   md.text('Are you really sure ? ') | ||||
|   if TkComm.bool(md.activate) | ||||
|     puts 'Yes' | ||||
|   else | ||||
|     puts 'No' | ||||
|   end | ||||
| else | ||||
|   puts 'No' | ||||
| end | ||||
| 
 | ||||
| md.destroy | ||||
| 
 | ||||
| # | ||||
| # Copyright notice with automatic deactivation. | ||||
| # | ||||
| bmp = '@' + File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/text.xbm') | ||||
| 
 | ||||
| cr = Tk::Iwidgets::Messagedialog.new(:title=>'Copyright',  | ||||
| 				     :bitmap=>bmp, :imagepos=>:n,  | ||||
| 				     :text=>"Copyright 200x XXX Corporation\nAll rights reserved") | ||||
| 
 | ||||
| cr.hide('Cancel') | ||||
| 
 | ||||
| cr.activate | ||||
| Tk.after(7000, proc{cr.deactivate; Tk.root.destroy}) | ||||
| 
 | ||||
| mainloop.join | ||||
							
								
								
									
										13
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| rb = Tk::Iwidgets::Radiobox.new(:labeltext=>'Fonts') | ||||
| rb.add('times',     :text=>'Times') | ||||
| rb.add('helvetica', :text=>'Helvetica') | ||||
| rb.add('courier',   :text=>'Courier') | ||||
| rb.add('symbol',    :text=>'Symbol') | ||||
| rb.select('courier') | ||||
| rb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10) | ||||
| 
 | ||||
| Tk.mainloop | ||||
							
								
								
									
										7
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| Tk::Iwidgets::Timeentry.new.pack | ||||
| 
 | ||||
| Tk.mainloop | ||||
							
								
								
									
										8
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| tf = Tk::Iwidgets::Timefield.new(:command=>proc{puts(tf.get)}) | ||||
| tf.pack(:fill=>:x, :expand=>true, :padx=>10,  :pady=>10) | ||||
| 
 | ||||
| Tk.mainloop | ||||
							
								
								
									
										18
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/watch.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								ext/tk/sample/tkextlib/iwidgets/sample/watch.rb
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| #!/usr/bin/env ruby | ||||
| require 'tk' | ||||
| require 'tkextlib/iwidgets' | ||||
| 
 | ||||
| Thread.new{ | ||||
|   trap('INT') {puts 'catch SIGINT'} | ||||
|   sleep 5 | ||||
|   trap('INT', 'DEFAULT') | ||||
| } | ||||
| 
 | ||||
| Tk::Iwidgets::Watch.new(:state=>:disabled, :showampm=>:no,  | ||||
| 			:width=>155, :height=>155){|w| | ||||
|   w.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true) | ||||
|   # TkTimer.new(1000, -1, proc{w.show; Tk.update}).start | ||||
|   TkTimer.new(25, -1, proc{w.show; Tk.update}).start | ||||
| } | ||||
| 
 | ||||
| Tk.mainloop | ||||
|  | @ -214,6 +214,10 @@ tk_symbolkey2str(self, keys) | |||
| { | ||||
|     volatile VALUE new_keys = rb_hash_new(); | ||||
| 
 | ||||
|     if NIL_P(keys) return new_keys; | ||||
|     if (TYPE(keys) != T_HASH) { | ||||
| 	rb_raise(rb_eArgError, "Hash is expected"); | ||||
|     } | ||||
|     st_foreach(RHASH(keys)->tbl, to_strkey, new_keys); | ||||
|     return new_keys; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 nagai
						nagai