ETLayoutItem+Scrollable

Authors

Quentin Mathe (qmathe@club-internet.fr)
Syntactic sugar to insert and remove scrollers very easily on a layout item.

Copyright: (C) 2009 Quentin Mathe

Software documentation for the ETLayoutItem(Scrollable) category

ETLayoutItem(Scrollable)

Declared in:
ETLayoutItem+Scrollable.h

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.

Method summary

hasAnyVisibleScroller 

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


hasHorizontalScroller 

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


hasVerticalScroller 

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


isScrollable 

- (BOOL) isScrollable;

Returns wether the receiver content is enclosed in a scrollable area.

See -setScrollable: .


setHasHorizontalScroller: 

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


setHasVerticalScroller: 

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


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)

updateScrollableAreaItemVisibility 

- (void) updateScrollableAreaItemVisibility;

Hides or shows the cached scrollable area item based on whether the current layout controls the scrollers visibility or not.

You should never need to call this method which is used internally.