Documentation

ETDecoratorItem

ETDecoratorItem : ETUIItem

ETUIItem subclass which makes possibe to decorate any layout items, usually with a widget view.

AuthorsQuentin Mathe
Declared inETDecoratorItem.h

Overview

Decorator class which can be subclassed to turn wrapper-like widgets such as scrollers, windows, group boxes etc., provided by the widget backend (e.g. AppKit), into decorator items to be applied to the semantic items that make up the layout item tree.

ETDecoratorItem can be seen as an ETLayoutItem variant with limited abilities and whose instances don't have a semantic role, hence they remain invisible in the layout item tree. They allow EtoileUI to maintain a very tight mapping between the model graph and the layout item tree. By limiting the number of non-semantic nodes in the tree, the feeling of working with real and cohesive objects is greatly enhanced at both code and UI level.

A decorator item must currently not break the following rules (this is subject to change though):
  • [self displayView] must return [[self decoratorItem] supervisorView]
  • [self supervisorView] must return [[[self decoratorItem] supervisorView] wrappedView]
However -supervisorView can be overriden to return nil.

You can write new ETDecoratorItem subclasses. However ETUIItem ivars must be considered private. If you don't present the decorated view as the wrapped view of the supervisor view, you must override -contentRect at least. You might also override -visibleRect and -visibleContentRect in some cases as ETScrollableAreaItem does.


Default

+ (id) itemWithObjectGraphContext: (COObjectGraphContext *)aContext

Do not use. May be remove later.

    - (id) initWithSupervisorView: (ETView *)aSupervisorView objectGraphContext: (COObjectGraphContext *)aContext

    Initializes and returns a new decorator whose decoration border is provided by supervisorView.

    If you write a subclass that uses no supervisor view, you must override this initializer.

      - (BOOL) usesWidgetView

      Returns whether the view used by the receiver is a widget.

      By default, returns YES.

        - (void) setDecorationRect: (NSRect)rect

        Set the decoration rect associated with the receiver.

        If you want to intercept a decoration rect update, see -handleSetDecorationRect: .

          - (void) setAutoresizingMask: (unsigned int)aMask

          Sets the autoresizing mask of the supervisor view.

            - (NSRect) visibleRect

            Returns the content rect portion that remains visible when the content is clipped. The visible rect is expressed in the content coordinate space unlike -visibleContentRect .

              - (NSRect) visibleContentRect

              Returns the content rect portion that remains visible when the content is clipped. The visible content rect is expressed in the receiver coordinate space. See also -contentRect .

              When the content is not clipped by the receiver, -visibleContentRect and -contentRect are equal.

              With ETDecoratorItem, the content rect and the visible content rect are equal, because the content is resized rather than clipped when a decorator is resized. However subclasses can decide otherwise (e.g. ETScrollableAreaItem).

                - (NSRect) contentRect

                Returns the content rect expressed in the receiver coordinate space (the area that lies inside -decorationRect).

                The receiver content rect is equal to [[self decoratedItem] decorationRect].

                  - (NSRect) convertDecoratorRectFromContent: (NSRect)rectInContent

                  Returns a rect expressed in the receiver coordinate space equivalent to rect parameter expressed in the receiver content coordinate space.

                  The receiver coordinate space is the area that lies inside -decorationRect . The receiver content coordinate space is the area that lies inside -contentRect .

                  See also -convertDecoratorRectToContent: .

                    - (NSPoint) convertDecoratorPointFromContent: (NSPoint)aPoint

                    Returns a point expressed in the receiver coordinate space equivalent to point parameter expressed in the receiver content coordinate space.

                    See also -convertDecoratorRectFromContent:.

                      - (NSRect) convertDecoratorRectToContent: (NSRect)rectInDecorator

                      Returns a rect expressed in the receiver content coordinate space equivalent to rect parameter expressed in the receiver coordinate space.

                      For extra details, see -convertDecoratorRectFromContent:.

                        - (NSPoint) convertDecoratorPointToContent: (NSPoint)aPoint

                        Returns a point expressed in the receiver coordinate space equivalent to point parameter expressed in the receiver content coordinate space.

                        See also -convertDecoratorRectToContent: .

                          - (NSSize) decorationSizeForContentSize: (NSSize)aSize
                          Description forthcoming.
                            - (BOOL) isFlipped
                            Description forthcoming.
                              - (void) setFlipped: (BOOL)flipped
                              Description forthcoming.
                                - (BOOL) canDecorateItem: (ETUIItem *)item

                                Returns whether item can be decorated by the receiver.

                                You can override this method to restrict which item kinds can be decorated by the receiver. However you must only return YES when the superclass implementation returns the same.

                                  - (void) handleDecorateItem: (ETUIItem *)item supervisorView: (ETView *)decoratedView inView: (ETView *)parentView

                                  Overrides to customize how the receiver is set up when it is inserted with -setDecorator: .

                                  This methods provides a basic implemention that works well when a subclass uses a supervisor view. Whether you extend this behavior or replace it, you must call the superclass implementation.

                                  To take over the decorated item insertion into the receiver supervisor view, pass nil as decoratedView. To take over the outermost decorator insertion into the parent niew, pass nil as parentView. This last case is only useful when the receiver will be inserted as the last decorator.

                                  • decoratedView is equal to [ item supervisorView]
                                  • parentView is equal to [[ item displayView] superview]

                                  Take in account that parentView can be nil.

                                    - (void) handleUndecorateItem: (ETUIItem *)item supervisorView: (ETView *)decoratedView inView: (ETView *)parentView

                                    Overrides to customize how the receiver is torn down when it is removed with -setDecorator: nil.

                                    This methods provides a basic implemention that works well when a subclass uses a supervisor view. Whether you extend this behavior or replace it, you must call the superclass implementation.

                                    To take over the decorated item removal from the receiver supervisor view, pass nil as decoratedView. To take over the outermost decorator removal from the parent view, pass nil as parentView. This case is only useful when the receiver is currently the last decorator.

                                    Take in account that parentView can be nil.

                                      - (void) saveAndOverrideAutoresizingMaskOfDecoratedItem: (ETUIItem *)item

                                      Sets the last decorator item autoresizing mask to match the given item, then overrides the given item autoresizing mask with NSViewWidthSizable and NSViewHeightSizable.

                                        - (void) restoreAutoresizingMaskOfDecoratedItem: (ETUIItem *)item

                                        Sets the given item autoresizing mask to match the last decorator item.

                                          - (NSRect) frameForDecoratedItemFrame: (NSRect)aFrame

                                          Returns the given frame.

                                          When -setDecoratorItem: is invoked, this method is called on the new last decorator.

                                          Can be overriden to return an adjusted frame.

                                          For example, ETWindowItem returns an extended rect to include the window border.

                                            - (NSRect) frameForUndecoratedItemFrame: (NSRect)aFrame

                                            Returns the given frame.

                                            When -setDecoratorItem: is invoked, this method is called on the previous last decorator.

                                            Can be overriden to return an adjusted frame.

                                            For example, ETWindowItem returns an shrinked rect to exclude the window border.

                                              - (void) handleSetDecorationRect: (NSRect)rect

                                              This method updates the decoration rect associated with the receiver.

                                              You can override this method to customize how a subclass react to a geometry update when the receiver is the outermost decorator item. A common use case is when a subclass uses a custom decoration rect (unrelated to the supervisor view extent).

                                              You must never call this method, but only override it.

                                              NOTE: This purpose will probably evolved a bit later on...

                                                - (NSSize) decoratedItemRectChanged: (NSRect)rect

                                                This method notifies the receiver that the decorated item has a new decoration rect. The existing implementation simply notifies the next decorator, and so on recursively. When the outermost decorator item is reached, -handleSetDecorationRect: is called. Finally rect.size is returned.

                                                rect is in the receiver content coordinate space.

                                                You can override this method to customize how a subclass react to an inner geometry update. A custom content size can be returned when needed. A common use case is to intercept decorated item resizes to clip or extend the requested receiver content size.

                                                You must never call this method, but only override it.

                                                  - (void) setDecoratedItem: (ETUIItem *)item

                                                  Sets the decorated item associated with the receiver.

                                                  You should never need to call this method.

                                                    - (ETUIItem *) decoratedItemAtPoint: (NSPoint)aPoint
                                                    Description forthcoming.