+++ /dev/null
-/*\r
- * Ext JS Library 0.30\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.air.SystemMenu\r
- * \r
- * Provides platform independent handling of adding item to the application menu, creating the menu or \r
- * items as needed. <br/><br/>\r
- * \r
- * This class also provides the ability to bind standard Ext.Action instances with NativeMenuItems\r
- * \r
- * @singleton\r
- */\r
-Ext.air.SystemMenu = function(){\r
- var menu;\r
- // windows\r
- if(air.NativeWindow.supportsMenu && nativeWindow.systemChrome != air.NativeWindowSystemChrome.NONE) {\r
- menu = new air.NativeMenu();\r
- nativeWindow.menu = menu;\r
- }\r
- \r
- // mac\r
- if(air.NativeApplication.supportsMenu) {\r
- menu = air.NativeApplication.nativeApplication.menu;\r
- }\r
-\r
- function find(menu, text){\r
- for(var i = 0, len = menu.items.length; i < len; i++){\r
- if(menu.items[i]['label'] == text){\r
- return menu.items[i];\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- return {\r
- /**\r
- * Add items to one of the application menus\r
- * @param {String} text The application menu to add the actions to (e.g. 'File' or 'Edit').\r
- * @param {Array} actions An array of Ext.Action objects or menu item configs\r
- * @param {Number} mindex The index of the character in "text" which should be used for \r
- * keyboard access\r
- * @return air.NativeMenu The raw submenu\r
- */\r
- add: function(text, actions, mindex){\r
-\r
- var item = find(menu, text);\r
- if(!item){\r
- item = menu.addItem(new air.NativeMenuItem(text));\r
- item.mnemonicIndex = mindex || 0;\r
-\r
- item.submenu = new air.NativeMenu();\r
- }\r
- for (var i = 0, len = actions.length; i < len; i++) {\r
- item.submenu.addItem(actions[i] == '-' ? new air.NativeMenuItem("", true) : Ext.air.MenuItem(actions[i]));\r
- }\r
- return item.submenu;\r
- },\r
- \r
- /**\r
- * Returns the application menu\r
- */\r
- get : function(){\r
- return menu;\r
- }\r
- }; \r
-}();\r
-\r
-// ability to bind native menu items to an Ext.Action\r
-Ext.air.MenuItem = function(action){\r
- if(!action.isAction){\r
- action = new Ext.Action(action);\r
- }\r
- var cfg = action.initialConfig;\r
- var nativeItem = new air.NativeMenuItem(cfg.itemText || cfg.text);\r
- \r
- nativeItem.enabled = !cfg.disabled;\r
-\r
- if(!Ext.isEmpty(cfg.checked)){\r
- nativeItem.checked = cfg.checked;\r
- }\r
-\r
- var handler = cfg.handler;\r
- var scope = cfg.scope;\r
- \r
- nativeItem.addEventListener(air.Event.SELECT, function(){\r
- handler.call(scope || window, cfg);\r
- });\r
- \r
- action.addComponent({\r
- setDisabled : function(v){\r
- nativeItem.enabled = !v;\r
- },\r
- \r
- setText : function(v){\r
- nativeItem.label = v;\r
- },\r
- \r
- setVisible : function(v){\r
- // could not find way to hide in air so disable?\r
- nativeItem.enabled = !v;\r
- },\r
- \r
- setHandler : function(newHandler, newScope){\r
- handler = newHandler;\r
- scope = newScope;\r
- },\r
- // empty function\r
- on : function(){}\r
- });\r
- \r
- return nativeItem;\r
-}\r