Public Member Functions | |
Managed representers | |
Managing the list of representers laid out by the receiver | |
(NSArray *) | - representers |
(void) | - addRepresenter: |
(void) | - removeRepresenter: |
Configuration | |
(void) | - setMaximizesBytesPerLine: |
(BOOL) | - maximizesBytesPerLine |
Layout | |
Methods to get information about layout, and to explicitly trigger it. | |
(CGFloat) | - minimumViewWidthForLayoutInProposedWidth: |
(NSUInteger) | - maximumBytesPerLineForLayoutInProposedWidth: |
(CGFloat) | - minimumViewWidthForBytesPerLine: |
(void) | - performLayout |
HFLayoutRepresenter has an array of representers attached to it. When you add an HFRepresenter to this array, HFLayoutRepresenter will add the view of the representer as a subview of its own view.
Layout
HFLayoutRepresenter is capable of arranging the views of other HFRepresenters to fit within the bounds of its view. The layout process depends on three things:
frame
and autoresizingMask
of the representers' views.minimumViewWidthForBytesPerLine:
method, which determines the largest number of bytes per line that the representer can display for a given view width.layoutPosition
. This is an NSPoint, but it is not used geometrically. Instead, the relative values of the X and Y coordinates of the layoutPosition
determine the relative positioning of the views, as described below.
Thus, to have your subclass of HFRepresenter participate in the HFLayoutRepresenter system, override defaultLayoutPosition:
to control its positioning, and possibly \c minimumViewWidthForBytesPerLine: if your representer requires a certain width to display some bytes per line. Then ensure your view has its autoresizing mask set properly, and if its frame is fixed size, ensure that its frame is correct as well.
The layout process, in detail, is:
layoutPosition
into "slices." Smaller values appear towards the bottom of the layout view. There is no space between slices.layoutPosition
, with smaller values appearing on the left.NSViewHeightSizable
set. If there is any leftover vertical space, it is distributed equally among all slices with at least one view with NSViewHeightSizable
set.minimumViewWidthForBytesPerLine:
NSViewWidthSizable
set in their autoresizing mask. - (NSArray *) representers |
Return the array of representers managed by the receiver.
- (void) addRepresenter: | (HFRepresenter *) | representer |
Adds a new representer to the receiver, triggering relayout.
- (void) removeRepresenter: | (HFRepresenter *) | representer |
Removes a representer to the receiver (which must be present in the receiver's array of representers), triggering relayout.
- (void) setMaximizesBytesPerLine: | (BOOL) | val |
Sets whether the receiver will attempt to maximize the bytes per line so as to consume as much as possible of the bounds rect. If this is YES, then upon relayout, the receiver will recalculate the maximum number of bytes per line that can fit in its boundsRectForLayout. If this is NO, then the receiver will not change the bytes per line.
- (BOOL) maximizesBytesPerLine |
Returns whether the receiver maximizes the bytes per line.
- (CGFloat) minimumViewWidthForLayoutInProposedWidth: | (CGFloat) | proposedWidth |
Returns the smallest width that produces the same layout (and, if maximizes bytesPerLine, the same bytes per line) as the proposed width.
- (NSUInteger) maximumBytesPerLineForLayoutInProposedWidth: | (CGFloat) | proposedWidth |
Returns the maximum bytes per line that can fit in the proposed width (ignoring maximizesBytesPerLine). This is always a multiple of the bytesPerColumn, and always at least bytesPerColumn.
- (CGFloat) minimumViewWidthForBytesPerLine: | (NSUInteger) | bytesPerLine |
Returns the smallest width that can support the given bytes per line.
Reimplemented from HFRepresenter.
- (void) performLayout |
Relayouts are triggered when representers are added and removed, or when the view is resized. You may call this explicitly to trigger a relayout.