Layout class (Menu)

Layout(oMenu, oItem)

new Layout(oMenu, oItem)

The Layout object holds the layout to display all visible parts for the item and its descendents. The layout is built by the Layout() constructor, which is invoked by the Menu control to build the layout for the root item, and then for each sub-menu item that requires a different layout (such as a tab item). The Layout object holds the size of the layout, and the visible parts to be shown into the current layout. The Layout object provides methods to enumerate the visible parts within the layout, and to specify whether an item is a popup or group-popup within the current layout.
Parameters:
Name Type Description
oMenu Menu Specifies the Menu object to build the layout for.
oItem Item Points to an object of Item type that specifies the item to build the layout for.

Methods

feI(view, offset, callback, thisArg)

The feI() method (short for forEachItem) method enumerates the items of the current layout that fits the view, while the layout is displayed at giving offset. The feI() method groups the parts of each item into a single object and provides it to the callback, to avoid multiple calls for each part of the same item.
Parameters:
Name Type Description
view null | Array.<number> Indicates an array of [x,y,width,height] type that specifies the client rectangle the current layout is displayed to. If the view is null/missing/undefined all parts of the layout are being returned.
offset object Indicates an object of {x,y} type that specifies the relative-offset to show each part of the layout.
callback callback A callback method to be invoked for each item fits the view. The callback provides two parameters as explained:
oItem {Item}, indicates an object of Item type that indicates the item that displays the parts
rgParts {object}, indicates an object of exontrol.M1([Item.PartEnum => [x,y,width,height]]) type contains all parts of item
thisArg any Specifies the value of this keyword during the callback.
Example
The following sample displays the caption and parts of each item in the new layout once a new layout for the menu has been built:

 oMenu.on("layoutchange", function(oEvent)
 {
   oEvent.feI(function(oItem, rgParts)
   {
     console.log(oItem.caption, rgParts.toA());
   })
 })

where oMenu is an object of Menu type
feI

forEach(callback, thisArg, view, offset)

The forEach() method enumerates the parts of the current layout that fits the view, while the layout is displayed at the giving offset. The callback is invoked for each part that fits the view, and it provides the item, part and rectangle to show the part.
Parameters:
Name Type Description
callback callback A callback method to be invoked for each part that fits the view. The callback provides three parameters as explained:
oItem {Item}, indicates an object of Item type that indicates the item that displays the part
part {Item.PartEnum}, specifies the part of the item to be displayed
rtPart {number[]}, indicates an array of [x,y,width,height] type that specifies the rectangle to show the item's part (if offset parameter is present, it offsets the rtItem as well )
thisArg any Specifies the value of this keyword during the callback.
view null | Array.<number> Indicates an array of [x,y,width,height] type that specifies the client rectangle the current layout is displayed to. If the view is null/missing/undefined all parts of the layout are being returned (@since 5.3).
offset object Indicates an object of {x,y} type that specifies the relative-offset to show each part of the layout (@since 5.3).
Example
The following sample displays the item, part and rectangle of each part in the new layout once a new layout for the menu has been built:

 oMenu.on("layoutchange", function(oEvent)
 {
   oEvent.forEach(function(oItem, part, rtPart)
   {
     console.log(oItem, part, rtPart);
   })
 })

where oMenu is an object of Menu type
forEach