ETDecoratorItem

Authors

Quentin Mathe (qmathe@club-internet.fr)
ETUIItem subclass which makes possibe to decorate any layout items, usually with a widget view.

Copyright: (C) 2009 Quentin Mathe

Software documentation for the ETDecoratorItem class

ETDecoratorItem : ETUIItem

Declared in:
ETDecoratorItem.h

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):

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.

Method summary

itemWithObjectGraphContext: 

+ (id) itemWithObjectGraphContext: (COObjectGraphContext*)aContext;

Do not use. May be remove later.


canDecorateItem: 

- (BOOL) canDecorateItem: (ETUIItem*)item;
An empty method provided for subclasses to override.

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.


contentRect 

- (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].


convertDecoratorPointFromContent: 

- (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: .


convertDecoratorPointToContent: 

- (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: .


convertDecoratorRectFromContent: 

- (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: .


convertDecoratorRectToContent: 

- (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: .


decoratedItemAtPoint: 

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

decoratedItemRectChanged: 

- (NSSize) decoratedItemRectChanged: (NSRect)rect;
An empty method provided for subclasses to override.

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.


decorationSizeForContentSize: 

- (NSSize) decorationSizeForContentSize: (NSSize)aSize;
Description forthcoming.

frameForDecoratedItemFrame: 

- (NSRect) frameForDecoratedItemFrame: (NSRect)aFrame;
An empty method provided for subclasses to override.

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.


frameForUndecoratedItemFrame: 

- (NSRect) frameForUndecoratedItemFrame: (NSRect)aFrame;
An empty method provided for subclasses to override.

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.


handleDecorateItem: supervisorView: inView: 

- (void) handleDecorateItem: (ETUIItem*)item supervisorView: (ETView*)decoratedView inView: (ETView*)parentView;
An empty method provided for subclasses to override.

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.


handleSetDecorationRect: 

- (void) handleSetDecorationRect: (NSRect)rect;
An empty method provided for subclasses to override.

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...


handleUndecorateItem: supervisorView: inView: 

- (void) handleUndecorateItem: (ETUIItem*)item supervisorView: (ETView*)decoratedView inView: (ETView*)parentView;
An empty method provided for subclasses to override.

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.


initWithSupervisorView: objectGraphContext: 

- (id) initWithSupervisorView: (ETView*)aSupervisorView objectGraphContext: (COObjectGraphContext*)aContext;
This is a designated initialiser for the class.

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.


isFlipped 

- (BOOL) isFlipped;
Description forthcoming.

restoreAutoresizingMaskOfDecoratedItem: 

- (void) restoreAutoresizingMaskOfDecoratedItem: (ETUIItem*)item;
An empty method provided for subclasses to override.

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


saveAndOverrideAutoresizingMaskOfDecoratedItem: 

- (void) saveAndOverrideAutoresizingMaskOfDecoratedItem: (ETUIItem*)item;
An empty method provided for subclasses to override.

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


setAutoresizingMask: 

- (void) setAutoresizingMask: (unsigned int)aMask;
An empty method provided for subclasses to override.

Sets the autoresizing mask of the supervisor view.


setDecoratedItem: 

- (void) setDecoratedItem: (ETUIItem*)item;

Sets the decorated item associated with the receiver.

You should never need to call this method.


setDecorationRect: 

- (void) setDecorationRect: (NSRect)rect;
Subclasses must NOT override this method.

Set the decoration rect associated with the receiver.

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


setFlipped: 

- (void) setFlipped: (BOOL)flipped;
Description forthcoming.

usesWidgetView 

- (BOOL) usesWidgetView;

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

By default, returns YES.


visibleContentRect 

- (NSRect) visibleContentRect;
An empty method provided for subclasses to override.

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).


visibleRect 

- (NSRect) visibleRect;
An empty method provided for subclasses to override.

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 .