ETLayoutItem categories documentation
Scrollable
ETLayoutItem (Scrollable)Overview
This ETLayoutItem category manages ETScrollableAreaItem insertion and removal in the receiver decorator chain. You can use it rather than interacting directly with a scrollable area item you set up and remove manually.
You can set a scrollable area item with -setDecoratorItem: on a layout item and it will be then managed by this category. Which means methods like -[ETLayoutItem setHasVerticalScroller:] can still be used transparently.
The scrollable are item is also automatically removed or inserted, based on wether or not the receiver layout comes with built-in scroll support. e.g. widget layouts such as ETTableLayout or ETBrowserLayout.
By altering the scroller visibility with this category, you can be sure you won't have to reconfigure the scrollable area item even when you remove it or it gets removed. It will be reinserted when scrollers are reenabled, because scrollable area items handed to -[ETLayoutItem setDecoratorItem:] are cached.
Don't use -setScrollable: initially to make the scrollers visible, but -setHasVerticalScroller: or -setHasHorizontalScroller: , -setScrollable: only inserts or removes the scrollable area item.
A new scrollable area item has no visible scrollers.
Default
- - (BOOL) hasVerticalScroller
Returns YES when the vertical scroller of the current scroll view managed by the receiver or its layout is visible, otherwise returns NO.
- - (void) setHasVerticalScroller: (BOOL)scroll
Sets the vertical scroller visibility of the current scrollable area that can be owned either by the receiver or its layout.
Even if both vertical and horizontal scroller are made invisible, this method won't remove the scrollable area decorator managed by the receiver from the decorator chain.
Marks the receiver as needing a layout update.
- - (BOOL) hasHorizontalScroller
Returns YES when the horizontal scroller of the current scrollable area managed by the receiver or its layout is visible, otherwise returns NO.
- - (void) setHasHorizontalScroller: (BOOL)scroll
Sets the horizontal scroller visibility of the current scrollable area that can be owned either by the receiver or its layout.
Even if both vertical and horizontal scrollers are made invisible, this method won't remove the scrollable area decorator managed by the receiver from the decorator chain.
Marks the receiver as needing a layout update.
- - (BOOL) hasAnyVisibleScroller
Returns whether the horizontal scroller, the vertical scroller or both are visible.
This method returns NO when no scroller is visible, even when -hasHorizontalScroller or -hasVerticalScroller return YES.
- - (BOOL) isScrollable
Returns wether the receiver content is enclosed in a scrollable area.
See -setScrollable: .
- - (void) setScrollable: (BOOL)scrollable
Sets wether the receiver content is enclosed in a scrollable area.
When -hasAnyVisibleScrollers returns NO, scrollers won't become visible when the receiver is requested to become scrollable.
The scrollable area role can be embodied by:- the decorator (i.e. [self decoratorItem] is a scrollable area item)
- the layout (i.e. the layout returns YES to -hasScrollers)
KVO
ETLayoutItem (KVO)Overview
WARNING: Unstable API.
Default
- - (NSSet *) observableKeyPaths
Returns the observable properties.
This method is only invoked when -addObserver: is used. e.g. ETPropertyViewpoint doesn't use it to observe a layout item.
We also expose some NSObject properties as observable such as -UTI.
You must call the superclass implementation when you override this method.
You must not make weak references observable unless you nullify them explicitly when the object they reference is going to be deallocated.
You must not use a setter to nullify a weak reference, because this can result in a KVO notification when the setter owner is currently being observed.
e.g. Nullifying the 'parentItem' backward pointer with [item setParentItem: nil] results in a KVO notification when the child is observed by some other object. The issue is that the old 'parentItem' value can be retained by the KVO change dictionary when the 'parentItem' deallocation is underway. Which means, that when the change dictionary is released, the 'parentItem' will be sent -release too. At this point, the parent item retain count is zero and -dealloc will be incorrectly reentered.
