diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-12 22:13:13 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-12 22:13:13 +0000 |
commit | 2850b7c4812894a616bca1af09f901fe9a202fb0 (patch) | |
tree | 84346c413e2b49c3e9e42fbd431345c172191169 /ext/tk | |
parent | 598e9930183162bb8cee510b7931e87a20e2e497 (diff) | |
download | ruby-2850b7c4812894a616bca1af09f901fe9a202fb0.tar.gz |
tk.rb : add 'no_create' option to widget initialize method.
It allows to create ruby objects for widgets created on Tcl/Tk.
(e.g. TkButton.new('widgetname'=>'.bbb', 'no_create'=>true) )
It is useful for some Tcl/Tk Mega Widgets.
MANIFEST, README : forgot to commit when added tkmacpkg.rb and tkwinpkg.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-rw-r--r-- | ext/tk/MANIFEST | 2 | ||||
-rw-r--r-- | ext/tk/lib/README | 2 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 32 |
3 files changed, 28 insertions, 8 deletions
diff --git a/ext/tk/MANIFEST b/ext/tk/MANIFEST index bf03ac3841..5280553ba3 100644 --- a/ext/tk/MANIFEST +++ b/ext/tk/MANIFEST @@ -11,12 +11,14 @@ lib/tkclass.rb lib/tkdialog.rb lib/tkentry.rb lib/tkfont.rb +lib/tkmacpkg.rb lib/tkmenubar.rb lib/tkmngfocus.rb lib/tkpalette.rb lib/tkscrollbox.rb lib/tktext.rb lib/tkvirtevent.rb +lib/tkwinpkg.rb sample/tkbiff.rb sample/tkbrowse.rb sample/tkdialog.rb diff --git a/ext/tk/lib/README b/ext/tk/lib/README index 87b59f4972..2d9e72bced 100644 --- a/ext/tk/lib/README +++ b/ext/tk/lib/README @@ -7,9 +7,11 @@ tkclass.rb provides generic names for Tk classes tkdialog.rb Tk dialog class tkentry.rb Tk entry class tkfont.rb Tk font support +tkmacpkg.rb Mac resource support tkmenubar.rb TK menubar utility tkmngfocus.rb focus manager tkpalette.rb pallete support tkscrollbox.rb scroll box, also example of compound widget tktext.rb text classes tkvirtevent.rb virtual event support +tkwinpkg.rb Win DDE and registry support diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 8463e370a8..ec1ee8f8c0 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -282,7 +282,9 @@ module TkComm name = format("w%.4d", Tk_IDs[1]) Tk_IDs[1] += 1 end - if !ppath or ppath == "." + if name[0] == ?. + @path = name.dup + elsif !ppath or ppath == "." @path = format(".%s", name); else @path = format("%s.%s", ppath, name) @@ -2596,29 +2598,43 @@ class TkWindow<TkObject parent = keys.delete('parent') widgetname = keys.delete('widgetname') install_win(if parent then parent.path end, widgetname) + no_create = keys.delete('no_create') + if no_create && !widgetname + fail ArgumentError, + "if 'no_create' option set true, need to define 'widgetname'" + end elsif keys keys = _symbolkey2str(keys) widgetname = keys.delete('widgetname') install_win(if parent then parent.path end, widgetname) + no_create = keys.delete('no_create') + if no_create && !widgetname + fail ArgumentError, + "if 'no_create' option set true, need to define 'widgetname'" + end else install_win(if parent then parent.path end) end if self.method(:create_self).arity == 0 p 'create_self has no arg' if $DEBUG - create_self + create_self unless no_create if keys - # tk_call @path, 'configure', *hash_kv(keys) - configure(keys) + # tk_call @path, 'configure', *hash_kv(keys) + configure(keys) end else p 'create_self has args' if $DEBUG fontkeys = {} if keys - ['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key| - fontkeys[key] = keys.delete(key) if keys.key?(key) - } + ['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key| + fontkeys[key] = keys.delete(key) if keys.key?(key) + } + end + if no_create && keys + configure(keys) + else + create_self(keys) end - create_self(keys) font_configure(fontkeys) unless fontkeys.empty? end end |