diff --git a/ChangeLog b/ChangeLog index df8161030..e3a591d01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-11-17 fabien + + * Source/NSControl.m : Improved documentation + 2005-11-16 fabien * Source/NSColorPanel.m : Improved documentation diff --git a/Source/NSControl.m b/Source/NSControl.m index ca2c44384..859bc5b5e 100644 --- a/Source/NSControl.m +++ b/Source/NSControl.m @@ -48,6 +48,9 @@ static Class usedCellClass; static Class cellClass; static Class actionCellClass; +/**

TODO Description

+ */ + @implementation NSControl /* @@ -77,8 +80,8 @@ static Class actionCellClass; usedCellClass = factoryId ? factoryId : cellClass; } -/* - * Instance methods +/**

Initializes a new NSControl into the frame frameRect and create + a new NSCell

See Also: -setCell:

*/ - (id) initWithFrame: (NSRect)frameRect { @@ -98,14 +101,17 @@ static Class actionCellClass; [super dealloc]; } -/* - * Setting the Control's Cell +/**

Returns the NSControl's cell

See Also: -setCell:

*/ - (id) cell { return _cell; } +/**

Sets the NSControl's cell to aCell, Raises an NSInvalidArgumentException + exception if aCell is nil or if it is not a cell class

+

See Also: -cell

+ */ - (void) setCell: (NSCell *)aCell { if (aCell != nil && [aCell isKindOfClass: cellClass] == NO) @@ -115,14 +121,18 @@ static Class actionCellClass; ASSIGN(_cell, aCell); } -/* - * Enabling and Disabling the Control +/**

Returns whether the selected cell of the NSControl is enabled

+

See Also: -setEnabled:

*/ - (BOOL) isEnabled { return [[self selectedCell] isEnabled]; } +/**

Sets whether the NSControl's selected cell is enabled. + If flag is NO, this method abort the editing. This method marks self for + display

See Also: -isEnabled

+ */ - (void) setEnabled: (BOOL)flag { [[self selectedCell] setEnabled: flag]; @@ -131,14 +141,16 @@ static Class actionCellClass; [self setNeedsDisplay: YES]; } -/* - * Identifying the Selected Cell +/**

Returns the NSControl's selected cell

*/ - (id) selectedCell { return _cell; } +/**

Returns the tag of the NSControl's selected cell (if exists). + -1 otherwise

See Also: [NSCell-tag]

+ */ - (int) selectedTag { NSCell *selected = [self selectedCell]; @@ -149,8 +161,8 @@ static Class actionCellClass; return [selected tag]; } -/* - * Setting the Control's Value +/**

Returns the value if the NSControl's selected cell as double

+

See Also: [NSCell-doubleValue]

*/ - (double) doubleValue { @@ -158,16 +170,25 @@ static Class actionCellClass; return [[self selectedCell] doubleValue]; } +/**

Returns the value if the NSControl's selected cell as float

+

See Also: [NSCell-floatValue]

+ */ - (float) floatValue { return [[self selectedCell] floatValue]; } +/**

Returns the value if the NSControl's selected cell as int

+

See Also: [NSCell-intValue]

+ */ - (int) intValue { return [[self selectedCell] intValue]; } +/**

Returns the value if the NSControl's selected cell as NSString

+

See Also: [NSCell-stringValue]

+ */ - (NSString *) stringValue { return [[self selectedCell] stringValue]; @@ -178,6 +199,10 @@ static Class actionCellClass; return [[self selectedCell] objectValue]; } +/**

Sets the value if the NSControl's selected cell to double. + If the selected cell is an action cell, it marks self for display.

+

See Also: -doubleValue [NSCell-setDoubleValue:]

+ */ - (void) setDoubleValue: (double)aDouble { NSCell *selected = [self selectedCell]; @@ -193,6 +218,10 @@ static Class actionCellClass; } } +/**

Sets the value if the NSControl's selected cell to float. + If the selected cell is an action cell, it marks self for display.

+

See Also: -floatValue [NSCell-setFloatValue:]

+ */ - (void) setFloatValue: (float)aFloat { NSCell *selected = [self selectedCell]; @@ -208,6 +237,10 @@ static Class actionCellClass; } } +/**

Sets the value if the NSControl's selected cell to int. + If the selected cell is an action cell, it marks self for display.

+

See Also: -intValue [NSCell-setIntValue:]

+ */ - (void) setIntValue: (int)anInt { NSCell *selected = [self selectedCell]; @@ -223,6 +256,10 @@ static Class actionCellClass; } } +/**

Sets the value if the NSControl's selected cell to NSString. + If the selected cell is an action cell, it marks self for display.

+

See Also: stringValue [NSCell-setStringValue:]

+ */ - (void) setStringValue: (NSString *)aString { NSCell *selected = [self selectedCell]; @@ -253,6 +290,8 @@ static Class actionCellClass; } } +/**

Marks self for display

+*/ - (void) setNeedsDisplay { [super setNeedsDisplay: YES]; @@ -291,8 +330,9 @@ static Class actionCellClass; [self setNeedsDisplay: YES]; } -/* - * Formatting Text +/**

Returns the alignment of the text in the NSControl's cell. + Returns NSNaturalTextAlignment if the cell does not exists

+

See Also: -setAlignment:

*/ - (NSTextAlignment) alignment { @@ -302,6 +342,10 @@ static Class actionCellClass; return NSNaturalTextAlignment; } +/**

Returns the font of the text in the NSControl's cell. + Returns nil if the cell does not exists

+

See Also: -setFont:

+ */ - (NSFont *) font { if (_cell) @@ -310,6 +354,10 @@ static Class actionCellClass; return nil; } +/**

Sets the alignment of the text in the NSControl's cell. + This method abort the editing and marks self for display if the cell + is an NSActionCell

See Also: -alignment

+ */ - (void) setAlignment: (NSTextAlignment)mode { if (_cell) @@ -322,6 +370,9 @@ static Class actionCellClass; } } +/**

Sets the font of the text in the NSControl's cell.

+

See Also: -font

+ */ - (void) setFont: (NSFont *)fontObject { if (_cell) @@ -361,56 +412,60 @@ static Class actionCellClass; return [_cell formatter]; } -/* - * Managing the Field Editor +/**

Sends an [NSCell-endEditing:] message to the current object used to + edit the NSControl. Returns NO if the the currentEditor does not exists, + YES otherwise.

*/ - (BOOL) abortEditing { - NSText *t; + NSText *text; - t = [self currentEditor]; - if (t == nil) + text = [self currentEditor]; + if (text == nil) { return NO; } - [[self selectedCell] endEditing: t]; + [[self selectedCell] endEditing: text]; return YES; } + - (NSText *) currentEditor { if (_cell != nil) { - NSText *t; + NSText *text; - t = [_window fieldEditor: NO forObject: self]; - if (([t delegate] == self) && ([_window firstResponder] == t)) + text = [_window fieldEditor: NO forObject: self]; + if (([text delegate] == self) && ([_window firstResponder] == text)) { - return t; + return text; } } return nil; } +/** + */ - (void) validateEditing { - NSText *t; + NSText *text; - t = [self currentEditor]; - if (t == nil) + text = [self currentEditor]; + if (text == nil) { return; } - if ([t isRichText]) + if ([text isRichText]) { NSAttributedString *attr; NSTextStorage *storage; int len; - storage = [(NSTextView*)t textStorage]; + storage = [(NSTextView*)text textStorage]; len = [storage length]; attr = [storage attributedSubstringFromRange: NSMakeRange(0, len)]; [[self selectedCell] setAttributedStringValue: attr]; @@ -419,26 +474,28 @@ static Class actionCellClass; { NSString *string; - string = AUTORELEASE([[t string] copy]); + string = AUTORELEASE([[text string] copy]); [[self selectedCell] setStringValue: string]; } } -/* - * Resizing the Control +/**

Recalculates the internal size by sending [NSCell-calcDrawInfo:] + to the cell.

*/ - (void) calcSize { [_cell calcDrawInfo: [self bounds]]; } +/**

Resizes the NSControl to fits the NSControl's cell size

+

See Also: [NSCell-cellSize]

+ */ - (void) sizeToFit { [self setFrameSize: [_cell cellSize]]; } -/* - * Displaying the Control and Cell +/**

Returns whether the NSControl's cell is opaque

*/ - (BOOL) isOpaque { @@ -467,6 +524,8 @@ static Class actionCellClass; } } +/**

Selects aCell if it's the NSControl's cell

+ */ - (void) selectCell: (NSCell *)aCell { if (_cell == aCell) @@ -476,24 +535,33 @@ static Class actionCellClass; } } + +/**

Marks self for display

+ */ - (void) updateCell: (NSCell *)aCell { [self setNeedsDisplay: YES]; } +/**

Marks self for display

+ */ - (void) updateCellInside: (NSCell *)aCell { [self setNeedsDisplay: YES]; } -/* - * Target and Action +/**

Returns the NSControl's cell action method

+

See Also: -setAction: [NSCell-action]

*/ - (SEL) action { return [_cell action]; } +/**

Returns whether the NSControl's cell can continuously sends its action + message

+

See Also: -setContinuous: [NSCell-isContinuous]

+ */ - (BOOL) isContinuous { return [_cell isContinuous]; @@ -512,21 +580,33 @@ static Class actionCellClass; return [_cell sendActionOn: mask]; } +/**

Sets the NSControl's cell action method

+

See Also: -action [NSCell-setAction:]

+*/ - (void) setAction: (SEL)aSelector { [_cell setAction: aSelector]; } +/**

Sets whether the NSControl's cell can continuously sends its action + message

See Also: -isContinuous [NSCell-setContinuous:]

+*/ - (void) setContinuous: (BOOL)flag { [_cell setContinuous: flag]; } +/**

Sets the target object of the NSControl's cell to anObject

+

See Also: -target [NSCell-setTarget:]

+ */ - (void) setTarget: (id)anObject { [_cell setTarget: anObject]; } +/**

Returns the target object of the NSControl's cell

+

See Also: -setTarget: [NSCell-target]

+ */ - (id) target { return [_cell target]; @@ -562,7 +642,7 @@ static Class actionCellClass; return [selected attributedStringValue]; } -/* +/** * Assigning a Tag */ - (void) setTag: (int)anInt