Public Member Functions | |
(NSUInteger) | - byteGranularity |
View management | |
Methods related to accessing and initializing the representer's view. | |
(id) | - view |
(BOOL) | - isViewLoaded |
(NSView *) | - NS_RETURNS_RETAINED |
(void) | - initializeView |
Accessing the HFController | |
(HFController *) | - controller |
Property change notifications | |
(void) | - controllerDidChange: |
HFController convenience methods | |
(NSUInteger) | - bytesPerLine |
(NSUInteger) | - bytesPerColumn |
(void) | - representerChangedProperties: |
Measurement | |
Methods related to measuring the HFRepresenter, so that it can be laid out properly by an HFLayoutController. All of these methods are candidates for overriding. | |
(NSUInteger) | - maximumBytesPerLineForViewWidth: |
(CGFloat) | - minimumViewWidthForBytesPerLine: |
(double) | - maximumAvailableLinesForViewHeight: |
Auto-layout methods | |
Methods for simple auto-layout by HFLayoutRepresenter. See the HFLayoutRepresenter class for discussion of how it lays out representer views. | |
(void) | - setLayoutPosition: |
(NSPoint) | - layoutPosition |
(NSPoint) | + defaultLayoutPosition |
HFRepresenters also have a view, accessible through the -view method. The HFRepresenter is expected to update its view to reflect the relevant properties of its HFController. If the user can interact with the view, then the HFRepresenter should pass any changes down to the HFController, which will subsequently notify all HFRepresenters of the change.
HFRepresenter is an abstract class, with a different subclass for each possible view type. Because HFController interacts with HFRepresenters, rather than views directly, an HFRepresenter can use standard Cocoa views and controls.
To add a new view type:
-createView
to return a view (note that this method should transfer ownership)-controllerDidChange
:, checking the bitmask to see what properties have changed and updating your view as appropriate+defaultLayoutPosition
to control how your view gets positioned in an HFLayoutRepresenter+maximumBytesPerLineForViewWidth
:, so that your view gets sized correctly - (id) view |
Returns the view for the receiver, creating it if necessary. The view for the HFRepresenter is initially nil. When the -view
method is called, if the view is nil, -createView
is called and then the result is stored. This method should not be overridden; however you may want to call it to access the view.
- (BOOL) isViewLoaded |
Returns YES if the view has been created, NO if it has not. To create the view, call the view method.
- (NSView *) NS_RETURNS_RETAINED |
Override point for creating the view displaying this representation. This is called on your behalf the first time the -view
method is called, so you would not want to call this explicitly; however this method must be overridden. This follows the "create" rule, and so it should return a retained view.
- (void) initializeView |
Override point for initialization of view, after the HFRepresenter has the view set as its -view property. The default implementation does nothing.
- (HFController *) controller |
Returns the HFController for the receiver. This is set by the controller from the call to addRepresenter:
. A representer can only be in one controller at a time.
- (void) controllerDidChange: | (HFControllerPropertyBits) | bits |
Indicates that the properties indicated by the given bits did change, and the view should be updated as to reflect the appropriate properties. This is the main mechanism by which representers are notified of changes to the controller.
- (NSUInteger) bytesPerLine |
Equivalent to [[self controller] bytesPerLine]
- (NSUInteger) bytesPerColumn |
Equivalent to [[self controller] bytesPerColumn]
- (void) representerChangedProperties: | (HFControllerPropertyBits) | properties |
Equivalent to [[self controller] representer:self changedProperties:properties]
. You may call this when some internal aspect of the receiver's view (such as its frame) has changed in a way that may globally change some property of the controller, and the controller should recalculate those properties. For example, the text representers call this with HFControllerDisplayedLineRange when the view grows vertically, because more data may be displayed.
- (NSUInteger) maximumBytesPerLineForViewWidth: | (CGFloat) | viewWidth |
Returns the maximum number of bytes per line for the given view size. The default value is NSUIntegerMax, which means that the representer can display any number of lines for the given view size.
- (CGFloat) minimumViewWidthForBytesPerLine: | (NSUInteger) | bytesPerLine |
Returns the minimum view frame size for the given bytes per line. Default is to return 0, which means that the representer can display the given bytes per line in any view size. Fixed width views should return their fixed width.
Reimplemented in HFLayoutRepresenter.
- (double) maximumAvailableLinesForViewHeight: | (CGFloat) | viewHeight |
Returns the maximum number of lines that could be displayed at once for a given view height. Default is to return DBL_MAX.
- (NSUInteger) byteGranularity |
Returns the required byte granularity. HFLayoutRepresenter will constrain the bytes per line to a multiple of the granularity, e.g. so that UTF-16 characters are not split across lines. If different representers have different granularities, then it will constrain it to a multiple of all granularities, which may be very large. The default implementation returns 1.
- (void) setLayoutPosition: | (NSPoint) | position |
Sets the receiver's layout position to the given value.
- (NSPoint) layoutPosition |
Returns the layout position for the receiver.
+ (NSPoint) defaultLayoutPosition |
Returns the default layout position for representers of this class. Within the -init method, the view's layout position is set to the default for this class. You may override this to control the default layout position. See HFLayoutRepresenter for a discussion of the significance of the layout postition.