diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-12 15:25:49 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-12 15:25:49 +0000 |
commit | 7050e0c745982d4c8c5d7088df21b63fbfc172bc (patch) | |
tree | 7ff4193ecbd0de9f6d52bb230b3b5c826103ccff /ext/tk/lib/tk/toplevel.rb | |
parent | 7d4fe15675ba17e775082965ebbea648b4753b58 (diff) |
* ext/tcltklib/extconf.rb: [EXPERIMENTAL] MacOS X (darwin) support
* ext/tcltklib/tcltklib.c: fix thread trouble on callback proc, and
eliminate warning about instance variable access
* ext/tk/lib/tk/menubar.rb: improve supported menu_spec
* ext/tk/lib/tk/menuspec.rb: [add] menu_spec support library
* ext/tk/lib/tk/root.rb: add menu_spec support
* ext/tk/lib/tk/text.rb: bug fix
* ext/tk/lib/tk/toplevel.rb: add menu_spec support
* ext/tk/sample/menubar?.rb: [add] sample of menu_spec usage
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk/toplevel.rb')
-rw-r--r-- | ext/tk/lib/tk/toplevel.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb index b7f9bed740..c95002dbeb 100644 --- a/ext/tk/lib/tk/toplevel.rb +++ b/ext/tk/lib/tk/toplevel.rb @@ -3,9 +3,11 @@ # require 'tk' require 'tk/wm' +require 'tk/menuspec' class TkToplevel<TkWindow include Wm + include TkMenuSpec TkCommandNames = ['toplevel'.freeze].freeze WidgetClassName = 'Toplevel'.freeze @@ -169,6 +171,25 @@ class TkToplevel<TkWindow @classname end + def add_menu(menu_info, tearoff=false, opts=nil) + # See tk/menuspec.rb for menu_info. + # opts is a hash of default configs for all of cascade menus. + # Configs of menu_info can override it. + if tearoff.kind_of?(Hash) + opts = tearoff + tearoff = false + end + _create_menubutton(self, menu_info, tearoff, opts) + end + + def add_menubar(menu_spec, tearoff=false, opts=nil) + # See tk/menuspec.rb for menu_spec. + # opts is a hash of default configs for all of cascade menus. + # Configs of menu_spec can override it. + menu_spec.each{|info| add_menu(info, tearoff, opts)} + self.menu + end + def self.database_class if self == WidgetClassNames[WidgetClassName] || self.name == '' self |