Documentation

ETLayoutItemGroup

ETLayoutItemGroup : ETLayoutItem <ETLayoutingContext, ETWidgetLayoutingContext, ETItemSelection, ETCollection, ETCollectionMutation>

A layout item tree node which can contain arbitrary ETLayoutItem subclass instances.

AuthorsQuentin Mathe
Declared inETLayoutItemGroup.h

Overview

You must never subclass ETLayoutItemGroup.


Traversing the Layout Item Tree

- (ETLayoutItem *) itemAtIndexPath: (NSIndexPath *)path

Returns the layout item child identified by the index path parameter interpreted as relative to the receiver.

For an empty path, returns self.

For a nil path, returns nil.

Returns the layout item child identified by the index path parameter interpreted as relative to the receiver.

For an empty path, returns self.

For a nil path, returns nil.

    - (ETLayoutItem *) itemForIdentifier: (NSString *)anId

    Returns the first layout item descendant on which the identifier is set.

    The descendant items are retrieved with -allDescendantItems , this results in a pre-order traversal.

    Use this method cautiously when the item tree is big (e.g. more than 10 000 items).

    See also -identifier .

      Debugging

      - (NSString *) descriptionWithProperty: (NSString *)aProperty arranged: (BOOL)usesArrangedItems

      Returns an indented tree description by traversing the tree with -arrangedItems to get the children if usesArrangedItems is YES, otherwise with -items .

      When aProperty is a valid property name, each item description includes the value bound to this property.

      See also -[NSObject descriptionWithOptions:] .

      Returns an indented tree description by traversing the tree with -arrangedItems to get the children if usesArrangedItems is YES, otherwise with -items .

      When aProperty is a valid property name, each item description includes the value bound to this property.

      See also -[NSObject descriptionWithOptions:] .

        Accessing and Mutating Items

        - (void) addItem: (ETLayoutItem *)item

        Adds the given item to the receiver children.

        Adds the given item to the receiver children.

          - (void) insertItem: (ETLayoutItem *)item atIndex: (NSUInteger)index

          Inserts the given item in the receiver children at a precise index.

            - (void) removeItem: (ETLayoutItem *)item

            Removes the given item from the receiver children.

              - (void) removeItemAtIndex: (NSUInteger)index

              Removes the child item at the given index in the receiver children.

                - (ETLayoutItem *) itemAtIndex: (NSInteger)index

                Returns the child item at the given index in the receiver children.

                  - (ETLayoutItem *) firstItem

                  Returns the first receiver child item.

                  Shortcut method equivalent to [self itemAtIndex: 0].

                  Similar to -firstObject method for collections (see ETCollection).

                    - (ETLayoutItem *) lastItem

                    Returns the last receiver child item.

                    Shortcut method equivalent to [self itemAtIndex: [self numberOfItems] - 1].

                    Similar to -lastObject method for collections (see ETCollection).

                      - (NSInteger) indexOfItem: (id)item

                      Returns the index of the given child item in the receiver children.

                        - (BOOL) containsItem: (ETLayoutItem *)item

                        Returns whether the given item is a receiver child or not.

                          - (NSInteger) numberOfItems

                          Returns how many child items the receiver includes.

                            - (void) addItems: (NSArray *)items

                            Adds the given the items to the receiver children.

                              - (void) removeItems: (NSArray *)items

                              Removes the given child items from the receiver children.

                                - (void) removeAllItems

                                Removes all the receiver child items.

                                  - (NSArray *) items

                                  Returns an autoreleased array which contains the receiver child items.

                                    Accessing Descendant Items

                                    - (NSArray *) descendantItemsSharingSameBaseItem

                                    Returns the descendant items, including the immediate children, that share the same base item than the receiver.

                                    An item is said to be under the control of an item group, when you can traverse the branch leading to the item without crossing a base item. An item group becomes a base item when a represented path base is set, in other words when -representedPathBase doesn't return nil. See also -isBaseItem .

                                    This method collects every item in the layout item subtree (excluding the receiver) by doing a preorder traversal, the resulting collection is a flat list of every item in the tree.

                                    If you are interested by collecting descendant items in another traversal order, you have to implement your own version of this method.

                                    Returns the descendant items, including the immediate children, that share the same base item than the receiver.

                                    An item is said to be under the control of an item group, when you can traverse the branch leading to the item without crossing a base item. An item group becomes a base item when a represented path base is set, in other words when -representedPathBase doesn't return nil. See also -isBaseItem .

                                    This method collects every item in the layout item subtree (excluding the receiver) by doing a preorder traversal, the resulting collection is a flat list of every item in the tree.

                                    If you are interested by collecting descendant items in another traversal order, you have to implement your own version of this method.

                                      - (NSArray *) allDescendantItems

                                      Returns all descendant items of the receiver, including immediate children.

                                      This method collects every item in the layout item subtree (excluding the receiver) by doing a preorder traversal, the resulting collection is a flat list of every item in the tree.

                                      If you are interested in collecting descendant items in another traversal order, you have to implement your own version of this method.

                                        - (BOOL) isDescendantItem: (ETLayoutItem *)anItem

                                        Returns whether the item is a receiver descendant item.

                                        This method is a lot more efficient than using -allDescendantItems e.g. [[self allDescendantItems] containsItem: anItem] .

                                          Controlling Content Mutation and Item Providing

                                          - (BOOL) shouldMutateRepresentedObject

                                          Returns YES when the item tree mutation are propagated to the represented object, otherwise returns NO if it's up to you to reflect structural changes of the layout item tree onto the model object graph. By default, this method returns YES.

                                          Mutations are triggered by calling children or collection related methods like -addItem: , -insertItem:atIndex: , removeItem:, addObject: etc.

                                          The returned value is meaningful only if the receiver is a base item. In this case, the value applies to all related descendant items (by being looked up by descendant items).

                                          Returns YES when the item tree mutation are propagated to the represented object, otherwise returns NO if it's up to you to reflect structural changes of the layout item tree onto the model object graph. By default, this method returns YES.

                                          Mutations are triggered by calling children or collection related methods like -addItem: , -insertItem:atIndex: , removeItem:, addObject: etc.

                                          The returned value is meaningful only if the receiver is a base item. In this case, the value applies to all related descendant items (by being looked up by descendant items).

                                            - (void) setShouldMutateRepresentedObject: (BOOL)flag

                                            Sets whether the layout item tree mutation are propagated to the represented object or not.

                                            The value set is meaningful only if the receiver is a base item, otherwise the value is simply ignored.

                                              - (BOOL) usesRepresentedObjectAsProvider

                                              Returns YES when the child items are automatically generated by wrapping the elements of the represented object collection into ETLayoutItem or ETLayoutItemGroup instances.

                                              To use represented objects as providers in the layout item tree connected to the receiver, you have to set the source of the receiver to be the receiver itself. The code would be something like
                                              [itemGroupsetSource: itemGroup]
                                              .
                                                - (id) source

                                                Returns the source which provides the content presented by the receiver.

                                                A source implements either ETIndexSource or ETPathSource protocols. If the receiver handles the layout item tree directly without the help of a source object, then this method returns nil.

                                                  - (void) setSource: (id)source

                                                  Sets the source which provides the content displayed by the receiver. A source can be any objects conforming to ETIndexSource or ETPathSource protocol.

                                                  So you can write you own data source object by implementing either:
                                                    • -numberOfItemsInItemGroup:
                                                    • -itemGroup:itemAtIndex:
                                                    • -itemGroup:numberOfItemsAtPath:
                                                    • -itemGroup:itemAtPath:

                                                  Another common solution is to use the receiver itself as a source, in that case -usesRepresentedObjectAsProvider returns YES. And the receiver will generate the layout item tree bound to it by retrieving any child objects of the represented object (through ETCollection protocol) and wrapping them into ETLayoutItem or ETLayoutItemGroup objects based on whether these childs implements ETCollection or not.

                                                  You can also combine these abilities with an off-the-shelf controller object like ETController. See -setController to do so. This brings extra flexibility such as:
                                                  • template item and item group for the generated layout items
                                                  • easy to use add, insert and remove actions with template model object and model group for the represented objects to insert wrapped in layout items
                                                  • sorting
                                                  • searching

                                                  Finally when -source returns nil, it's always possible to build and manage a layout item tree structure in a static fashion by yourself.

                                                  When the new source is set, the content is immediately reloaded, and the layout updated unless the autolayout is disabled. Finally an ETSourceDidUpdateNotification is posted.

                                                  By setting a source, the receiver represented path base is automatically set to '/' unless another path was set previously. If you pass nil to get rid of a source, the represented path base isn't reset to nil but keeps its actual value in order to maintain it as a base item and avoid unpredictable changes to the event handling logic.

                                                  Marks the receiver as needing a layout update.

                                                    - (void) reloadIfNeeded

                                                    @@taskunit Reloading Items from Represented Object or Source

                                                    Tries to reload the content of the receiver, but only if it can be reloaded.

                                                    Won't reload when the receiver is currently sorted and/or filtered. See -isSorted and -isFiltered .

                                                    This method can be safely called even if the receiver has no source or doesn't inherit a source from a base item.

                                                    Marks the receiver as needing a layout update, if a reload occurs.

                                                    See also -reload .

                                                    Tries to reload the content of the receiver, but only if it can be reloaded.

                                                    Won't reload when the receiver is currently sorted and/or filtered. See -isSorted and -isFiltered .

                                                    This method can be safely called even if the receiver has no source or doesn't inherit a source from a base item.

                                                    Marks the receiver as needing a layout update, if a reload occurs.

                                                    See also -reload .

                                                      Controller and Delegate

                                                      - (id) delegate

                                                      Returns the delegate associated with the receiver.

                                                      See also -setDelegate: .

                                                      Returns the delegate associated with the receiver.

                                                      See also -setDelegate: .

                                                        - (void) setDelegate: (id)delegate

                                                        Sets the delegate associated with the receiver.

                                                        A delegate is only useful if the receiver is a base item, otherwise it will be ignored.

                                                        The delegate is retained, unlike what Cocoa/GNUstep usually do.

                                                        The delegate is owned by the item and treated as a pluggable aspect to be released when the item is deallocated.

                                                          - (ETController *) controller

                                                          Returns the controller which allows to customize the overall UI interaction with the receiver item tree.

                                                          When the controller is not nil, the receiver is both a base item and the controller content.

                                                            - (void) setController: (ETController *)aController

                                                            Sets the controller which allows to customize the overall UI interaction with the receiver item tree.

                                                            When the given controller is not nil, it is inserted as the next responder and the receiver becomes both a base item and the controller content.

                                                            See also -setSource: , -isBaseItem and -nextResponder .

                                                              Layout

                                                              - (id) layout

                                                              Returns the layout associated with the receiver to present its content.

                                                              Returns the layout associated with the receiver to present its content.

                                                                - (void) setLayout: (ETLayout *)layout

                                                                Sets the layout associated with the receiver to present its content.

                                                                  - (void) updateLayout

                                                                  Updates recursively each layout in the item tree owned by the receiver.

                                                                  See -updateLayoutRecursively: .

                                                                    - (void) updateLayoutRecursively: (BOOL)recursively

                                                                    Updates each layout in the immediate children ( recursively is NO) or in the whole item subtree (recursively is YES) owned by the receiver.

                                                                    When recursively is YES, does a bottom-up layout update, by propagating it first downwards.

                                                                    Layout updates start on the terminal descendant items, then are carried upwards through the tree structure back to the receiver, whose layout is the last updated.

                                                                    A bottom-up update is used because a parent layout computation might depend on child item properties. For example, an item can use a layout which touches its frame (see -usesFlexibleLayoutFrame).

                                                                      Item Scaling

                                                                      - (CGFloat) itemScaleFactor

                                                                      Returns the scale factor applied to each item when the layout supports it.

                                                                      See also -setItemScaleFactor: .

                                                                      Returns the scale factor applied to each item when the layout supports it.

                                                                      See also -setItemScaleFactor: .

                                                                        - (void) setItemScaleFactor: (CGFloat)aFactor

                                                                        Sets the scale factor applied to each item when the layout supports it.

                                                                        This scale factor only applies to the immediate children.

                                                                        Updates the layout immediately unlike most methods.

                                                                        See -[ETLayout setItemSizeConstraintStyle:] and -[ETLayout setConstrainedItemSize:] to control more precisely how the items get resized per layout.

                                                                          Drawing

                                                                          - (void) render: (NSMutableDictionary *)inputValues dirtyRect: (NSRect)dirtyRect inContext: (id)ctxt

                                                                          See -[ETLayoutItem render:dirtyRect:inContext:] . The most important addition of this method is to manage the drawing of children items by calling this method recursively on them. The supervisor view or parent item intersects the dirty rect against the receiver drawing box just before calling -render:dirtyRect:inContext: . Which means the dirty rect needs no adjustments.

                                                                          See -[ETLayoutItem render:dirtyRect:inContext:] . The most important addition of this method is to manage the drawing of children items by calling this method recursively on them. The supervisor view or parent item intersects the dirty rect against the receiver drawing box just before calling -render:dirtyRect:inContext: . Which means the dirty rect needs no adjustments.

                                                                            Selection

                                                                            - (NSUInteger) selectionIndex

                                                                            Returns the index of the first selected item which is an immediate child of the receiver. If there is none, returns NSNotFound.

                                                                            Calling this method is equivalent to [[self selectionIndexes] firstIndex].

                                                                            Take note that -selectionIndexPaths may return one or multiple values when this method returns NSNotFound. See -selectionIndexes also.

                                                                            Returns the index of the first selected item which is an immediate child of the receiver. If there is none, returns NSNotFound.

                                                                            Calling this method is equivalent to [[self selectionIndexes] firstIndex].

                                                                            Take note that -selectionIndexPaths may return one or multiple values when this method returns NSNotFound. See -selectionIndexes also.

                                                                              - (void) setSelectionIndex: (NSUInteger)index

                                                                              Sets the selected item identified by index in the receiver and discards any existing selection index paths previously set.

                                                                              Posts an ETItemGroupSelectionDidChangeNotification.

                                                                                - (NSMutableIndexSet *) selectionIndexes

                                                                                Returns all indexes matching selected items which are immediate children of the receiver.

                                                                                Put in another way, the method returns the first index of all index paths with a length equal one.

                                                                                  - (void) setSelectionIndexes: (NSIndexSet *)indexes

                                                                                  Sets the selected items identified by indexes in the receiver and discards any existing selection index paths previously set.

                                                                                  Posts an ETItemGroupSelectionDidChangeNotification.

                                                                                    - (NSArray *) selectionIndexPaths

                                                                                    Returns the index paths of selected items in layout item subtree of the the receiver.

                                                                                      - (void) setSelectionIndexPaths: (NSArray *)indexPaths

                                                                                      Sets the selected items in the layout item subtree attached to the receiver.

                                                                                      Posts an ETItemGroupSelectionDidChangeNotification and marks the receiver to be redisplayed.

                                                                                        - (BOOL) isChangingSelection

                                                                                        Returns YES when a selection change initiated by -setSelectionIndex: , -setSelectionIndexes: or -setSelectionIndexPaths: is underway, otherwise returns NO.

                                                                                        During ETItemGroupSelectionDidChangeNotification and -[ETLayout didChangeSelectionInLayoutContext] will return YES.

                                                                                        You can use this method in ETLayout subclasses to prevent loops while synchronizing the selection between a widget and the item tree.

                                                                                        See -[ETWidgetLayout didChangeSelectionInLayoutView] .

                                                                                        e.g. Just put a guard clause at the beginning of -didChangeSelectionInLayoutView

                                                                                        if ([layoutContext isChangingSelection])
                                                                                        	return;
                                                                                        
                                                                                          - (NSArray *) selectedItems

                                                                                          Returns the selected child items belonging to the receiver.

                                                                                          The returned collection only includes immediate children, other selected descendant items below these childrens in the layout item subtree are excluded.

                                                                                            - (NSArray *) selectedItemsInLayout

                                                                                            Returns selected descendant items reported by the active layout through -[ETLayout selectedItems] .

                                                                                            You should call this method to obtain the selection in most cases and not -selectedItems .

                                                                                              - (void) setSelectedItems: (NSArray *)items

                                                                                              Sets the selected items in the layout item subtree attached to the receiver.

                                                                                              Posts an ETItemGroupSelectionDidChangeNotification and marks the receiver to be redisplayed.

                                                                                                Sorting and Filtering

                                                                                                - (void) sortWithSortDescriptors: (NSArray *)sortDescriptors recursively: (BOOL)recursively
                                                                                                Description forthcoming.
                                                                                                  - (void) filterWithPredicate: (NSPredicate *)predicate recursively: (BOOL)recursively
                                                                                                  Description forthcoming.
                                                                                                    - (NSArray *) arrangedItems

                                                                                                    Returns an array with the child items currently sorted and filtered, otherwise returns an array identical to -items .

                                                                                                    If the receiver has not been sorted or filtered yet, returns a nil array.

                                                                                                      - (BOOL) isSorted

                                                                                                      Returns whether -arrangedItems are sorted or not.

                                                                                                      See also -sortWithSortDescriptors:recursively:.

                                                                                                        - (BOOL) isFiltered

                                                                                                        Returns whether -arrangedItems are filtered or not.

                                                                                                        See also -filterWithPredicate:recursively:.

                                                                                                          Actions

                                                                                                          - (void) setDoubleAction: (SEL)selector

                                                                                                          Returns the action that can be sent by the action handler, typically on a double click within the receiver area.

                                                                                                          For a double action, the sender will be the receiver. The double clicked item can be retrieved by calling -doubleClickedItem on the sender in your action method.

                                                                                                          Returns the action that can be sent by the action handler, typically on a double click within the receiver area.

                                                                                                          For a double action, the sender will be the receiver. The double clicked item can be retrieved by calling -doubleClickedItem on the sender in your action method.

                                                                                                            - (SEL) doubleAction

                                                                                                            Sets the action that can be sent by the action handler, typically on a double click within the receiver area.

                                                                                                            See also -setDoubleAction: .

                                                                                                              - (ETLayoutItem *) doubleClickedItem

                                                                                                              Returns the last child item on which a double click occurs.

                                                                                                                - (BOOL) acceptsActionsForItemsOutsideOfFrame

                                                                                                                Returns whether the tools should hit test the children which intersect the area that lies outside the receiver frame but inside its bounding box.

                                                                                                                By default, returns NO.

                                                                                                                You can override this method to implement control points external to the receiver area as ETHandleGroup do.

                                                                                                                  Additions to ETCollectionMutation

                                                                                                                  - (ETLayoutItem *) insertObject: (id)object atIndex: (NSUInteger)index hint: (id)hint boxingForced: (BOOL)boxingForced
                                                                                                                  Description forthcoming.

                                                                                                                    Layouting Context Protocol

                                                                                                                    - (void) setLayoutView: (NSView *)aView

                                                                                                                    Inserts the given layout view into the supervisor view.

                                                                                                                    Inserts the given layout view into the supervisor view.

                                                                                                                      - (NSArray *) visibleItems

                                                                                                                      Returns the receiver visible child items.

                                                                                                                        - (void) setVisibleItems: (NSArray *)visibleItems

                                                                                                                        Sets the receiver visible child items, and mutates the view hierarchy when some items use a view. Views are inserted or removed to match the item visibility.

                                                                                                                        This method is invoked by the receiver layout just before -[ETLayout renderWithItems:isNewContent:] returns, to adjust the visibility of views and update each item visible property.

                                                                                                                        You shouldn't need to call this method by yourself.

                                                                                                                          - (NSSize) visibleContentSize
                                                                                                                          Description forthcoming.

                                                                                                                            Framework Private

                                                                                                                            - (BOOL) canReload

                                                                                                                            Returns whether the receiver can be reloaded presently with -reload .

                                                                                                                            Returns whether the receiver can be reloaded presently with -reload .

                                                                                                                              - (void) reload

                                                                                                                              Reloads the content by removing all existing childrens and requesting all the receiver immediate children to the base item source.

                                                                                                                              Will cancel any any sorting and/or filtering currently done on the receiver. Which means -isFiltered and -isSorted will both return NO.

                                                                                                                              Marks the receiver as needing a layout update.

                                                                                                                                - (void) handleAttachItem: (ETLayoutItem *)item

                                                                                                                                Handles any necessary adjustments to be done right before item is made a child item of the receiver. This method is available to be overriden in subclasses that want to extend or modify the item insertion behavior.

                                                                                                                                The default implementation takes to care to remove item from any existing parent item, then updates the parent item reference to be the receiver.

                                                                                                                                You must always call the superclass implementation.

                                                                                                                                Symetric method to -handleDetachItem:

                                                                                                                                  - (void) handleAttachViewOfItem: (ETLayoutItem *)item

                                                                                                                                  Inserts the display view of the given item into the receiver view.

                                                                                                                                  This method is used by -setVisibleItems: to manage view insertion. See also -handleDetachViewOfItem: and -[ETUItem displayView] .

                                                                                                                                    - (void) handleDetachItem: (ETLayoutItem *)item

                                                                                                                                    Handles any necessary adjustments to be done right before item is removed as a child item from the receiver. This method is available to be overriden in subclasses that want to extend or modify the item removal behavior.

                                                                                                                                    The default implementation only updates the parent item reference to be nil.

                                                                                                                                    You must always call the superclass implementation.

                                                                                                                                    Symetric method to -handleAttachItem:

                                                                                                                                      - (void) handleDetachViewOfItem: (ETLayoutItem *)item

                                                                                                                                      Removes the display view of the given view from the receiver view.

                                                                                                                                      This method is used by -setVisibleItems: to manage view removal. See also -handleAttachViewOfItem: and -[ETUIItem displayView] .

                                                                                                                                        - (void) didChangeSelection

                                                                                                                                        Tells the receiver the selection has been changed and it should post ETItemGroupSelectionDidChangeNotification.

                                                                                                                                        You should never use this method when you use -setSelected: on descendant items rather than setSelectionXXX: methods on the receiver.

                                                                                                                                          - (id) initAsLayerItemWithObjectGraphContext: (COObjectGraphContext *)aContext

                                                                                                                                          Initializes and returns a layer item to be encaspulated in a layout.

                                                                                                                                          You should never need to use this method.

                                                                                                                                          See also -isLayerItem .

                                                                                                                                            - (BOOL) isLayerItem

                                                                                                                                            Returns whether the receiver is a layer item encaspulated in a layout and invisible in the main layout item tree.

                                                                                                                                              Deprecated

                                                                                                                                              - (void) reloadAndUpdateLayout

                                                                                                                                              Attempts to reload the children items from the source and updates the layout by asking the first ancestor item with an opaque layout to do so.

                                                                                                                                              Attempts to reload the children items from the source and updates the layout by asking the first ancestor item with an opaque layout to do so.