ETLayoutItemFactory

Authors

Quentin Mathe (qmathe@club-internet.fr)
Factory for building various kinds of UI items and keeping track of special nodes of the layout item tree.

Copyright: (C) 2007 Quentin Mathe


Contents -

  1. Software documentation for the ETLayoutItemFactory class
  2. ETLayoutItemFactory constants

Software documentation for the ETLayoutItemFactory class

ETLayoutItemFactory : NSObject

Declared in:
ETLayoutItemFactory.h
Description forthcoming.
Method summary

factory 

+ (instancetype) factory;
Subclasses must NOT override this method.

@taskunit Initialization

Returns a shared instance that instantiates new items in a transient object graph context.

For each ETLayoutItemFactory subclass, returns a distinct shared instance. The object graph context remains the same accross all these shared instances.

Returns a shared instance that instantiates new items in a transient object graph context.

For each ETLayoutItemFactory subclass, returns a distinct shared instance. The object graph context remains the same accross all these shared instances.


factoryWithObjectGraphContext: 

+ (instancetype) factoryWithObjectGraphContext: (COObjectGraphContext*)aContext;
Subclasses must NOT override this method.

Returns a shared instance that instantiates new items in the given object graph context. For each ETLayoutItemFactory subclass and object graph context combination, returns a distinct shared instance.

For a nil context, raises an NSInvalidArgumentException.


barElementFromItem: withLabel: 

- (ETLayoutItem*) barElementFromItem: (ETLayoutItem*)anItem withLabel: (NSString*)aLabel;
Subclasses must NOT override this method.

Returns the layout item set up as a bar element with the given label and the shared style returned by -currentBarElementStyle .


barElementFromItem: withLabel: style: 

- (ETLayoutItem*) barElementFromItem: (ETLayoutItem*)anItem withLabel: (NSString*)aLabel style: (ETStyle*)aStyle;

Returns the layout item set up as a bar element with the given label and item style.


button 

- (id) button;

Returns a new layout item that uses a NSButton instance as its view.


buttonWithIconNamed: target: action: 

- (ETLayoutItem*) buttonWithIconNamed: (NSString*)aName target: (id)aTarget action: (SEL)anAction;

Returns a new layout item that uses a NSButton instance as its view, and initializes this button with the given target, action and the image bound to the given icon name.

The IconKit is used to looked up the icon image.

See also -buttonWithImage:target:action: .


buttonWithImage: target: action: 

- (id) buttonWithImage: (NSImage*)anImage target: (id)aTarget action: (SEL)aSelector;

Returns a new layout item that uses a NSButton instance as its view, and initializes this button with the given image, target and action.

See also -buttonWithIconNamed:target:action: .


buttonWithTitle: target: action: 

- (id) buttonWithTitle: (NSString*)aTitle target: (id)aTarget action: (SEL)aSelector;

Returns a new layout item that uses a NSButton instance as its view, and initializes this button with the given title, target and action.

The bezel style is set to NSRoundedBezelStyle on Mac OS X.


checkBox 

- (id) checkBox;
Subclasses must NOT override this method.

Returns a new layout item that uses a NSButton of type NSSwitchButton as its view. See also -checkboxWithLabel:target:action:forProperty:ofModel: .


checkboxWithLabel: target: action: forProperty: ofModel: 

- (id) checkboxWithLabel: (NSString*)aLabel target: (id)aTarget action: (SEL)aSelector forProperty: (NSString*)aKey ofModel: (id)aModel;

Returns a new layout item that uses a NSButton of type NSSwitchButton as its view, and initializes this checkbox with the given label, target and action.

You can provide a model object on which -setValue:forProperty: will be invoked for the given property every time the checkbox state changes.
The model object and property name are used to initialize a property viewpoint which is set as the returned item represented object. The property view point is also initialized to treat dictionary keys as properties, so you can use a dictionary as model.

Both model and property name must be valid objects when they are not nil.


collectionEditorWithSize: representedObject: controller: 

- (ETLayoutItemGroup*) collectionEditorWithSize: (NSSize)aSize representedObject: (id)aCollection controller: (id)aController;

Returns a new layout item group including a collection browser and buttons to edit the collection content using actions such as Add and Remove. Most items that make up the collection editor can be retrieved using -[ETLayoutItemGroup itemForIdentifier:] on the returned item group:

collectionEditor
the returned item group that encloses the collection editor UI
browser
the item group that presents the collection content
bar
the item group that contains the buttons at the bottom of the browser
plusButton
the item that calls the -add: action
minusButton
the item that calls the -remove: action
The bar that contains the buttons can be customized as desired. Just retrieve it using the right item identifier, and remove or add items to the returned item group.
For actions, the items in the bar must use the controller as the target usually (a nil target is not going to work to send a message to the controller, because the controller is not in the bar responder chain). The controller is bound to the browser item. For setting actions or double actions, once the method returns, just follow this example:
[[controller content] setDoubleAction: @selector(edit:)];
[[controller content] setTarget: controller];
The returned collection editor has a flexible width and a fixed height.

currentActionHandler 

- (ETActionHandler*) currentActionHandler;

Returns the shared action handler in the current object graph context.

See also -currentCoverStyle .


currentBarElementHeight 

- (CGFloat) currentBarElementHeight;

Returns the height applied to all the bar elements to be built.


currentBarElementStyle 

- (ETStyle*) currentBarElementStyle;

Returns the style applied to all the bar elements to be built.

Never returns nil.


currentCoverStyle 

- (ETStyle*) currentCoverStyle;

Aspect Sharing Boundaries and Persistency

Returns the shared cover style in the current object graph context.

See also -currentActionHandler .

Returns the shared cover style in the current object graph context.

See also -currentActionHandler .


defaultIconAndLabelBarHeight 

- (CGFloat) defaultIconAndLabelBarHeight;

Returns the standard bar height to fit labelled bar elements.

This bar height is set as the current bar element height when the receiver is initialized.

This height is also identical to the standard toolbar height in Aqua.


flexibleSpaceSeparator 

- (ETLayoutItem*) flexibleSpaceSeparator;

Returns a new layout item whose size can be adjusted by a computed layout based on the layout size and the available space.

A flexible space item can be shrinked to a zero size unlike the -spaceSeparator item.

The returned separator identifier is kETFlexibleSpaceItemIdentitifier.

See separator related methods in ETComputedLayout and subclasses.


graphicsGroup 

- (ETLayoutItemGroup*) graphicsGroup;

Returns a new layout item group set up as a graphics group with ETGraphicsGroupStyle as style and ETFreeLayout as layout.

You can use it to build structured graphics editor. e.g. ETSelectTool uses it when you request the grouping of several items.


horizontalBarWithSize: 

- (ETLayoutItemGroup*) horizontalBarWithSize: (NSSize)aSize;

Returns a new layout item group set up as an bar element group with ETBarStyle as style and ETLineLayout as layout.

Also resets the current bar element style to -[ETBasicItemStyle iconAndLabelBarElementStyleWithObjectGraphContext:] to ensure new bar elements share the same style.
And resets the current bar element height to the given size height.

The returned bar has a flexible width and a fixed height.


horizontalSlider 

- (id) horizontalSlider;

Returns a new layout item that uses a horizontally oriented NSSlider instance as its view.

The slider minimum value is set to 0, the maximum value to 100 and the initial value to 50.


horizontalSliderWithWidth: minValue: maxValue: forProperty: ofModel: 

- (id) horizontalSliderWithWidth: (CGFloat)aWidth minValue: (CGFloat)min maxValue: (CGFloat)max forProperty: (NSString*)aKey ofModel: (id)anObject;

Returns a new layout item that uses a horizontally oriented NSSlider instance as its view.


horizontalSliderWithWidth: minValue: maxValue: initialValue: target: action: 

- (id) horizontalSliderWithWidth: (CGFloat)aWidth minValue: (CGFloat)min maxValue: (CGFloat)max initialValue: (CGFloat)aValue target: (id)aTarget action: (SEL)aSelector;

Returns a new layout item that uses a horizontally oriented NSSlider instance as its view.


initWithObjectGraphContext: 

- (id) initWithObjectGraphContext: (COObjectGraphContext*)aContext;
This is a designated initialiser for the class.

Intializes and returns an item factory that instantiates new items in the given object graph context. For a nil context, raises an NSInvalidArgumentException.


item 

- (ETLayoutItem*) item;

Return a new blank layout item.


itemGroup 

- (ETLayoutItemGroup*) itemGroup;

Returns a new blank layout item group.


itemGroupWithFrame: 

- (ETLayoutItemGroup*) itemGroupWithFrame: (NSRect)aRect;

Returns a new blank layout item group initialized with the given frame.


itemGroupWithItem: 

- (ETLayoutItemGroup*) itemGroupWithItem: (ETLayoutItem*)item;

Returns a new layout item group which contains the given item as a child.

An NSInvalidArgumentException will be raised if you pass nil.


itemGroupWithItems: 

- (ETLayoutItemGroup*) itemGroupWithItems: (NSArray*)items;

Returns a new layout item group which contains the given items as children.


itemGroupWithRepresentedObject: 

- (ETLayoutItemGroup*) itemGroupWithRepresentedObject: (id)object;

Returns a new layout item group which represents the given object, usually a collection.

The represented object is a model object in an MVC perspective, the layout item group normally interacts with it through the Property Value Coding protocol and possibly the Collection protocols to traverse the object graph connected to it.

See also -itemWithRepresentedObject: .


itemGroupWithSize: 

- (ETLayoutItemGroup*) itemGroupWithSize: (NSSize)aSize;

Returns a new blank layout item group initialized with an origin at zero and the given size.


itemWithBezierPath: 

- (ETLayoutItem*) itemWithBezierPath: (NSBezierPath*)aPath;

Returns a new layout item which represents a custom shape based on the given bezier path. The shape is used as both the represented object and the style.


itemWithRepresentedObject: 

- (ETLayoutItem*) itemWithRepresentedObject: (id)object;

Returns a new layout item which represents the given object.

The represented object is a model object in an MVC perspective, the layout item normally interacts with it through the Property Value Coding protocol.

EtoileUI allows to manipulate every objects as a tangible object. To achieve that, every object is treated as a model object which can be represented on a screen by the mean of a layout item. Which means you can pass a layout item itself as a represented object and the returned item will be a proxy or a meta representation.


itemWithView: 

- (ETLayoutItem*) itemWithView: (NSView*)view;

Returns a new layout item to which the given view gets bound.


labelWithTitle: 

- (id) labelWithTitle: (NSString*)aTitle;

Returns a new label item that uses a NSTextField without border and background as its view.


lineSeparator 

- (ETLayoutItem*) lineSeparator;

Returns a new layout item that uses a NSBox instance as its view.

The returned separator is initially an horizontal line, but by resizing with a height greater than its width, it becomes a vertical line.


numberPicker 

- (ETLayoutItem*) numberPicker;
Description forthcoming.

numberPickerWithWidth: minValue: maxValue: initialValue: forProperty: ofModel: 

- (ETLayoutItem*) numberPickerWithWidth: (CGFloat)aWidth minValue: (double)min maxValue: (double)max initialValue: (double)aValue forProperty: (NSString*)aKey ofModel: (id)anObject;

Returns a new layout item that uses a view whose subviews are a text field and a stepper on the right side.


objectGraphContext 

- (COObjectGraphContext*) objectGraphContext;

@taskunit Object Graph Context


oval 

- (ETLayoutItem*) oval;

Returns a new layout item which represents an oval shape that fits in the width and height of +[ETShape defaultShapeRect].


ovalWithRect: 

- (ETLayoutItem*) ovalWithRect: (NSRect)aRect;

Returns a new layout item which represents an oval shape that fits in the width and height of the given rect.


pickboardGroup 

- (id) pickboardGroup;

Returns the item group representing all pickboards including both system-wide pickboards and those local to the current work context or application.

TODO: Finish to implement, the returned group is empty currently...


pointEditorWithWidth: forXProperty: yProperty: ofModel: 

- (ETLayoutItemGroup*) pointEditorWithWidth: (CGFloat)aWidth forXProperty: (NSString*)aXKey yProperty: (NSString*)aYKey ofModel: (id)anObject;
Description forthcoming.

popUpMenu 

- (ETLayoutItem*) popUpMenu;
Description forthcoming.

popUpMenuWithItemTitles: representedObjects: target: action: 

- (id) popUpMenuWithItemTitles: (NSArray*)entryTitles representedObjects: (NSArray*)entryModels target: (id)aTarget action: (SEL)aSelector;

Returns a new layout item that uses a NSPopUpButton instance as its view, and initializes this pop-up button with the given title, target, action and entries to be put in the menu.

When entryModels is not nil, each element is set as the represented object of the menu entry with the same index in entryTitles. You can pass [NSNull null] to set no represented object on a menu entry.


progressIndicator 

- (id) progressIndicator;

Returns a new layout item that uses a NSProgressIndicator instance as its view.


radioButton 

- (id) radioButton;

Returns a new layout item that uses a NSButton of type NSRadioButton as its view.


rectangle 

- (ETLayoutItem*) rectangle;

Returns a new layout item which represents a rectangular shape with the width and height of +[ETShape defaultShapeRect].


rectangleWithRect: 

- (ETLayoutItem*) rectangleWithRect: (NSRect)aRect;

Returns a new layout item which represents a rectangular shape with the width and height of the given rect.


searchFieldWithTarget: action: 

- (id) searchFieldWithTarget: (id)aTarget action: (SEL)aSelector;

Returns a new layout item that uses a NSSearchField instance as its view, and initializes this search field with the given target and action.


setCurrentBarElementHeight: 

- (void) setCurrentBarElementHeight: (CGFloat)aHeight;

Sets the height to apply to all the bar elements to be built.


setCurrentBarElementStyle: 

- (void) setCurrentBarElementStyle: (ETStyle*)aStyle;

Sets the style to apply to all the bar elements to be built.

If set to nil, -currentBarElementStyle is reset to its initial style.


sizeEditorWithWidth: forWidthProperty: heightProperty: ofModel: 

- (ETLayoutItemGroup*) sizeEditorWithWidth: (CGFloat)aWidth forWidthProperty: (NSString*)aWidthKey heightProperty: (NSString*)aHeightKey ofModel: (id)anObject;
Description forthcoming.

spaceSeparator 

- (ETLayoutItem*) spaceSeparator;

Returns a new layout item whose size can be adjusted by a computed layout based on the layout size and a minimum space size.

The returned separator name is kETSpaceItemIdentitifier.

See separator related methods in ETComputedLayout and subclasses.


stepper 

- (id) stepper;

Returns a new layout item that uses a NSStepper instance as its view.


textField 

- (ETLayoutItem*) textField;

Returns a new layout item that uses a NSTextField instance as its view.


textView 

- (id) textView;

Returns a new layout item that uses a NSTextView instance as its view. WARNING: presently returns a scrollview if you call -view on the returned item.


verticalSlider 

- (id) verticalSlider;

Returns a new layout item that uses a vertically oriented NSSlider instance as its view.


windowGroup 

- (ETLayoutItemGroup*) windowGroup;

Returns the item group representing all windows in the current work context or application.


ETLayoutItemFactory constants

kETFlexibleSpaceSeparatorItemIdentifier

NSString* const kETFlexibleSpaceSeparatorItemIdentifier;

Flexible space item name.


kETLineSeparatorItemIdentifier

NSString* const kETLineSeparatorItemIdentifier;

Line separator item name.


kETLineSeparatorMinimumSize

const NSUInteger kETLineSeparatorMinimumSize;

Line separator minimum width or height depending on the layout orientation (vertical vs horizontal).


kETSpaceSeparatorItemIdentifier

NSString* const kETSpaceSeparatorItemIdentifier;

Space item name.