PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/Sample/mx/managers/ISystemManager.as

https://github.com/ingydotnet/yaml-oscon2009-talk
ActionScript | 484 lines | 55 code | 54 blank | 375 comment | 0 complexity | c34870649320d46765e22e236e5ce95f MD5 | raw file
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // ADOBE SYSTEMS INCORPORATED
  4. // Copyright 2005-2007 Adobe Systems Incorporated
  5. // All Rights Reserved.
  6. //
  7. // NOTICE: Adobe permits you to use, modify, and distribute this file
  8. // in accordance with the terms of the license agreement accompanying it.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package mx.managers
  12. {
  13. import flash.display.DisplayObject;
  14. import flash.display.InteractiveObject;
  15. import flash.display.LoaderInfo;
  16. import flash.display.Sprite;
  17. import flash.display.Stage;
  18. import flash.events.Event;
  19. import flash.events.IEventDispatcher;
  20. import flash.geom.Rectangle;
  21. import flash.text.TextFormat;
  22. import mx.core.IChildList;
  23. import mx.core.IFlexModuleFactory;
  24. import mx.core.ISWFBridgeGroup;
  25. import mx.managers.IFocusManagerContainer;
  26. /**
  27. * An ISystemManager manages an "application window".
  28. * Every application that runs on the desktop or in a browser
  29. * has an area where the visuals of the application will be
  30. * displayed. It may be a window in the operating system
  31. * or an area within the browser. That is an "application window"
  32. * and different from an instance of <code>mx.core.Application</code>, which
  33. * is the main "top-level" window within an application.
  34. *
  35. * <p>Every application has an ISystemManager.
  36. * The ISystemManager sends an event if
  37. * the size of the application window changes (you cannot change it from
  38. * within the application, but only through interaction with the operating
  39. * system window or browser). It parents all displayable items within the
  40. * application, such as the main mx.core.Application instance and all popups,
  41. * tooltips, cursors, an so on. Any object parented by the ISystemManager is
  42. * considered to be a "top-level" window, even tooltips and cursors.</p>
  43. *
  44. * <p>The ISystemManager also switches focus between top-level windows
  45. * if there are more than one IFocusManagerContainer displayed and users
  46. * are interacting with components within the IFocusManagerContainers.</p>
  47. *
  48. * <p>All keyboard and mouse activity that is not expressly trapped is seen
  49. * by the ISystemManager, making it a good place to monitor activity
  50. * should you need to do so.</p>
  51. *
  52. * <p>If an application is loaded into another application, an ISystemManager
  53. * will still be created, but will not manage an "application window",
  54. * depending on security and domain rules.
  55. * Instead, it will be the <code>content</code> of the <code>Loader</code>
  56. * that loaded it and simply serve as the parent of the sub-application</p>
  57. *
  58. * <p>The ISystemManager maintains multiple lists of children, one each for
  59. * tooltips, cursors, popup windows.
  60. * This is how it ensures that popup windows "float" above the main
  61. * application windows and that tooltips "float" above that
  62. * and cursors above that.
  63. * If you examine the <code>numChildren</code> property
  64. * or <code>getChildAt()</code> method on the ISystemManager
  65. * you are accessing the main application window and any other windows
  66. * that aren't popped up.
  67. * To get the list of all windows, including popups, tooltips and cursors,
  68. * use the <code>rawChildren</code> property.</p>
  69. */
  70. public interface ISystemManager extends IEventDispatcher, IChildList, IFlexModuleFactory
  71. {
  72. //--------------------------------------------------------------------------
  73. //
  74. // Properties
  75. //
  76. //--------------------------------------------------------------------------
  77. //----------------------------------
  78. // cursorChildren
  79. //----------------------------------
  80. /**
  81. * An list of the custom cursors
  82. * being parented by this ISystemManager.
  83. *
  84. * <p>An ISystemManager has various types of children,
  85. * such as the Application, popups, top-most windows,
  86. * tooltips, and custom cursors.
  87. * You can access the custom cursors through
  88. * the <code>cursorChildren</code> property.</p>
  89. *
  90. * <p>The IChildList object has methods like <code>getChildAt()</code>
  91. * and properties like <code>numChildren</code>.
  92. * For example, <code>cursorChildren.numChildren</code> gives
  93. * the number of custom cursors (which will be either 0 or 1)
  94. * and, if a custom cursor exists, you can access it as
  95. * <code>cursorChildren.getChildAt(0)</code>.</p>
  96. */
  97. function get cursorChildren():IChildList;
  98. //----------------------------------
  99. // document
  100. //----------------------------------
  101. /**
  102. * A reference to the document object.
  103. * A document object is an Object at the top of the hierarchy of a
  104. * Flex application, MXML component, or AS component.
  105. */
  106. function get document():Object;
  107. /**
  108. * @private
  109. */
  110. function set document(value:Object):void;
  111. //----------------------------------
  112. // embeddedFontList
  113. //----------------------------------
  114. /**
  115. * @private
  116. */
  117. function get embeddedFontList():Object;
  118. //----------------------------------
  119. // focusPane
  120. //----------------------------------
  121. /**
  122. * A single Sprite shared among components used as an overlay for drawing focus.
  123. * You share it if you parent a focused component, not if you are IFocusManagerComponent.
  124. */
  125. function get focusPane():Sprite;
  126. /**
  127. * @private
  128. */
  129. function set focusPane(value:Sprite):void;
  130. //----------------------------------
  131. // loaderInfo
  132. //----------------------------------
  133. /**
  134. * The LoaderInfo object that represents information about the application.
  135. */
  136. function get loaderInfo():LoaderInfo;
  137. //----------------------------------
  138. // numModalWindows
  139. //----------------------------------
  140. /**
  141. * The number of modal windows.
  142. *
  143. * <p>Modal windows don't allow
  144. * clicking in another windows which would normally
  145. * activate the FocusManager in that window. The PopUpManager
  146. * modifies this count as it creates and destroy modal windows.</p>
  147. */
  148. function get numModalWindows():int;
  149. /**
  150. * @private
  151. */
  152. function set numModalWindows(value:int):void;
  153. //----------------------------------
  154. // popUpChildren
  155. //----------------------------------
  156. /**
  157. * An list of the topMost (popup)
  158. * windows being parented by this ISystemManager.
  159. *
  160. * <p>An ISystemManager has various types of children,
  161. * such as the Application, popups,
  162. * tooltips, and custom cursors.
  163. * You can access the top-most windows through
  164. * the <code>popUpChildren</code> property.</p>
  165. *
  166. * <p>The IChildList object has methods like <code>getChildAt()</code>
  167. * and properties like <code>numChildren</code>.
  168. * For example, <code>popUpChildren.numChildren</code> gives
  169. * the number of topmost windows and you can access them as
  170. * <code>popUpChildren.getChildAt(i)</code>.</p>
  171. *
  172. */
  173. function get popUpChildren():IChildList;
  174. //----------------------------------
  175. // rawChildren
  176. //----------------------------------
  177. /**
  178. * A list of all children
  179. * being parented by this ISystemManager.
  180. *
  181. * <p>An ISystemManager has various types of children,
  182. * such as the Application, popups,
  183. * tooltips, and custom cursors.</p>
  184. *
  185. * <p>The IChildList object has methods like <code>getChildAt()</code>
  186. * and properties like <code>numChildren</code>.</p>
  187. */
  188. function get rawChildren():IChildList;
  189. //----------------------------------
  190. // swfBridgeGroup
  191. //----------------------------------
  192. /**
  193. * Contains all the bridges to other applications
  194. * that this application is connected to.
  195. */
  196. function get swfBridgeGroup():ISWFBridgeGroup;
  197. //----------------------------------
  198. // screen
  199. //----------------------------------
  200. /**
  201. * The size and position of the application window.
  202. *
  203. * The Rectangle object contains <code>x</code>, <code>y</code>,
  204. * <code>width</code>, and <code>height</code> properties.
  205. */
  206. function get screen():Rectangle
  207. //----------------------------------
  208. // stage
  209. //----------------------------------
  210. /**
  211. * The flash.display.Stage that represents the application window
  212. * mapped to this SystemManager
  213. */
  214. function get stage():Stage
  215. //----------------------------------
  216. // toolTipChildren
  217. //----------------------------------
  218. /**
  219. * A list of the tooltips
  220. * being parented by this ISystemManager.
  221. *
  222. * <p>An ISystemManager has various types of children,
  223. * such as the Application, popups, topmost windows,
  224. * tooltips, and custom cursors.</p>
  225. *
  226. * <p>The IChildList object has methods like <code>getChildAt()</code>
  227. * and properties like <code>numChildren</code>.
  228. * For example, <code>toolTipChildren.numChildren</code> gives
  229. * the number of tooltips (which will be either 0 or 1)
  230. * and, if a tooltip exists, you can access it as
  231. * <code>toolTipChildren.getChildAt(0)</code>.</p>
  232. */
  233. function get toolTipChildren():IChildList;
  234. //----------------------------------
  235. // topLevelSystemManager
  236. //----------------------------------
  237. /**
  238. * The ISystemManager responsible for the application window.
  239. * This will be the same ISystemManager unless this application
  240. * has been loaded into another application.
  241. */
  242. function get topLevelSystemManager():ISystemManager;
  243. //--------------------------------------------------------------------------
  244. //
  245. // Methods
  246. //
  247. //--------------------------------------------------------------------------
  248. /**
  249. * Registers a top-level window containing a FocusManager.
  250. * Called by the FocusManager, generally not called by application code.
  251. *
  252. * @param f The top-level window in the application.
  253. */
  254. function addFocusManager(f:IFocusManagerContainer):void;
  255. /**
  256. * Unregisters a top-level window containing a FocusManager.
  257. * Called by the FocusManager, generally not called by application code.
  258. *
  259. * @param f The top-level window in the application.
  260. */
  261. function removeFocusManager(f:IFocusManagerContainer):void;
  262. /**
  263. * Activates the FocusManager in an IFocusManagerContainer.
  264. *
  265. * @param f IFocusManagerContainer the top-level window
  266. * whose FocusManager should be activated.
  267. */
  268. function activate(f:IFocusManagerContainer):void;
  269. /**
  270. * Deactivates the FocusManager in an IFocusManagerContainer, and activate
  271. * the FocusManager of the next highest window that is an IFocusManagerContainer.
  272. *
  273. * @param f IFocusManagerContainer the top-level window
  274. * whose FocusManager should be deactivated.
  275. */
  276. function deactivate(f:IFocusManagerContainer):void;
  277. /**
  278. * Converts the given String to a Class or package-level Function.
  279. * Calls the appropriate <code>ApplicationDomain.getDefinition()</code>
  280. * method based on
  281. * whether you are loaded into another application or not.
  282. *
  283. * @param name Name of class, for example "mx.video.VideoManager".
  284. *
  285. * @return The Class represented by the <code>name</code>, or null.
  286. */
  287. function getDefinitionByName(name:String):Object;
  288. /**
  289. * Returns <code>true</code> if this ISystemManager is responsible
  290. * for an application window, and <code>false</code> if this
  291. * application has been loaded into another application.
  292. *
  293. * @return <code>true</code> if this ISystemManager is responsible
  294. * for an application window.
  295. */
  296. function isTopLevel():Boolean;
  297. /**
  298. * Returns <code>true</code> if the required font face is embedded
  299. * in this application, or has been registered globally by using the
  300. * <code>Font.registerFont()</code> method.
  301. *
  302. * @param tf The TextFormat class representing character formatting information.
  303. *
  304. * @return <code>true</code> if the required font face is embedded
  305. * in this application, or has been registered globally by using the
  306. * <code>Font.registerFont()</code> method.
  307. */
  308. function isFontFaceEmbedded(tf:TextFormat):Boolean;
  309. /**
  310. * Tests if this system manager is the root of all
  311. * top level system managers.
  312. *
  313. * @return <code>true</code> if the SystemManager
  314. * is the root of all SystemManagers on the display list,
  315. * and <code>false</code> otherwise.
  316. */
  317. function isTopLevelRoot():Boolean;
  318. /**
  319. * Attempts to get the system manager that is the in the main application.
  320. *
  321. * @return The main application's systemManager if allowed by
  322. * security restrictions or null if it is in a different SecurityDomain.
  323. */
  324. function getTopLevelRoot():DisplayObject;
  325. /**
  326. * Gets the system manager is the root of all
  327. * top level system managers in this SecurityDomain
  328. *
  329. * @return the highest-level systemManager in the sandbox
  330. */
  331. function getSandboxRoot():DisplayObject;
  332. /**
  333. * Adds a child bridge to the system manager.
  334. * Each child bridge represents components in another sandbox
  335. * or compiled with a different version of Flex.
  336. *
  337. * @param bridge The bridge for the child.
  338. *
  339. * @param owner The SWFLoader for the child.
  340. */
  341. function addChildBridge(bridge:IEventDispatcher, owner:DisplayObject):void;
  342. /**
  343. * Adds a child bridge to the system manager.
  344. * Each child bridge represents components in another sandbox
  345. * or compiled with a different version of Flex.
  346. *
  347. * @param bridge The bridge for the child
  348. */
  349. function removeChildBridge(bridge:IEventDispatcher):void;
  350. /**
  351. * Dispatch a message to all parent and child applications in this SystemManager's SWF bridge group, regardless of
  352. * whether they are in the same SecurityDomain or not. You can optionally exclude an application with this method's parameters.
  353. *
  354. * @param event The event to dispatch.
  355. *
  356. * @param skip Specifies an IEventDispatcher that you do not want to dispatch a message to. This is typically used to skip the
  357. * IEventDispatcher that originated the event.
  358. *
  359. * @param trackClones Whether to keep a reference to the events as they are dispatched.
  360. *
  361. * @param toOtherSystemManagers Whether to dispatch the event to other top-level SystemManagers in AIR.
  362. */
  363. function dispatchEventFromSWFBridges(event:Event, skip:IEventDispatcher = null, trackClones:Boolean = false, toOtherSystemManagers:Boolean = false):void
  364. /**
  365. * Determines if the caller using this system manager
  366. * should should communicate directly with other managers
  367. * or if it should communicate with a bridge.
  368. *
  369. * @return <code>true</code> if the caller using this system manager
  370. * should communicate using sandbox bridges.
  371. * If <code>false</code> the system manager may directly call
  372. * other managers directly via references.
  373. */
  374. function useSWFBridge():Boolean;
  375. /**
  376. * Adds child to sandbox root in the layer requested.
  377. *
  378. * @param layer Name of IChildList in SystemManager
  379. *
  380. * @param child DisplayObject to add
  381. */
  382. function addChildToSandboxRoot(layer:String, child:DisplayObject):void;
  383. /**
  384. * Removes child from sandbox root in the layer requested.
  385. *
  386. * @param layer Name of IChildList in SystemManager
  387. *
  388. * @param child DisplayObject to add
  389. */
  390. function removeChildFromSandboxRoot(layer:String, child:DisplayObject):void;
  391. /**
  392. * Tests if a display object is in a child application
  393. * that is loaded in compatibility mode or in an untrusted sandbox.
  394. *
  395. * @param displayObject The DisplayObject to test.
  396. *
  397. * @return <code>true</code> if <code>displayObject</code>
  398. * is in a child application that is loaded in compatibility mode
  399. * or in an untrusted sandbox, and <code>false</code> otherwise.
  400. */
  401. function isDisplayObjectInABridgedApplication(
  402. displayObject:DisplayObject):Boolean;
  403. /**
  404. * Get the bounds of the loaded application that are visible to the user
  405. * on the screen.
  406. *
  407. * @param bounds Optional. The starting bounds for the visible rect. The
  408. * bounds are in global coordinates. If <code>bounds</code> is null the
  409. * starting bounds is defined by the <code>screen</code> property of the
  410. * system manager.
  411. *
  412. * @return a <code>Rectangle</code> including the visible portion of the this
  413. * object. The rectangle is in global coordinates.
  414. */
  415. function getVisibleApplicationRect(bounds:Rectangle = null):Rectangle;
  416. /**
  417. * Deploy or remove mouse shields. Mouse shields block mouse input to untrusted
  418. * applications. The reason you would want to block mouse input is because
  419. * when you are dragging over an untrusted application you would normally not
  420. * receive any mouse move events. The Flash Player does not send events
  421. * across trusted/untrusted boundries due to security concerns. By covering
  422. * the untrusted application with a mouse shield (assuming you are its parent)
  423. * you can get mouse move message and the drag operation will work as expected.
  424. *
  425. * @param deploy <code>true</code> to deploy the mouse shields, <code>false</code>
  426. * to remove the mouse shields.
  427. */
  428. function deployMouseShields(deploy:Boolean):void;
  429. }
  430. }