51 unsigned _resizingMask;
59 BOOL _disableResizingPosting;
74 - (id)initWithIdentifier:(
id)anIdentifier
84 _maxWidth = 1000000.0;
86 _disableResizingPosting = NO;
90 var header = [[_CPTableColumnHeaderView alloc] initWithFrame:CGRectMakeZero()];
104 _tableView = aTableView;
125 - (int)_tryToResizeToWidth:(
int)width
127 var min = [
self minWidth],
128 max = [
self maxWidth],
129 newWidth = ROUND(MIN(MAX(
width, min), max));
131 [
self setWidth:newWidth];
133 return newWidth -
width;
143 - (void)setWidth:(
float)aWidth
147 if (_width === aWidth)
150 var newWidth = MIN(MAX(aWidth, [
self minWidth]), [
self maxWidth]);
152 if (_width === newWidth)
155 var oldWidth = _width;
163 var index = [[tableView tableColumns] indexOfObjectIdenticalTo:self],
164 dirtyTableColumnRangeIndex = tableView._dirtyTableColumnRangeIndex;
166 if (dirtyTableColumnRangeIndex < 0)
167 tableView._dirtyTableColumnRangeIndex = index;
169 tableView._dirtyTableColumnRangeIndex = MIN(index, tableView._dirtyTableColumnRangeIndex);
171 var rows = tableView._exposedRows,
175 [tableView _layoutDataViewsInRows:rows columns:columns];
178 if (!_disableResizingPosting)
179 [
self _postDidResizeNotificationWithOldWidth:oldWidth];
195 - (void)setMinWidth:(
float)aMinWidth
197 aMinWidth = +aMinWidth;
199 if (_minWidth === aMinWidth)
202 _minWidth = aMinWidth;
205 newWidth = MAX(
width, [
self minWidth]);
207 if (
width !== newWidth)
223 - (void)setMaxWidth:(
float)aMaxWidth
225 aMaxWidth = +aMaxWidth;
227 if (_maxWidth === aMaxWidth)
230 _maxWidth = aMaxWidth;
233 newWidth = MIN(
width, [
self maxWidth]);
235 if (
width !== newWidth)
258 - (void)setResizingMask:(
unsigned)aResizingMask
260 _resizingMask = aResizingMask;
267 - (unsigned)resizingMask
269 return _resizingMask;
277 var
width = _CGRectGetWidth([_headerView
frame]);
279 if (
width < [
self minWidth])
281 else if (
width > [
self maxWidth])
284 if (_width !==
width)
305 var tableHeaderView = [_tableView headerView];
307 [tableHeaderView setNeedsLayout];
308 [tableHeaderView setNeedsDisplay:YES];
389 _dataViewData[[_dataView UID]] = nil;
410 - (id)dataViewForRow:(
int)aRowIndex
418 - (id)_newDataViewForRow:(
int)aRowIndex
420 var dataView = [
self dataViewForRow:aRowIndex],
421 dataViewUID = [dataView UID];
423 var x = [
self tableView]._cachedDataViews[dataViewUID];
428 if (!_dataViewData[dataViewUID])
433 newDataView.identifier = dataViewUID;
436 [newDataView setAutoresizingMask:CPViewNotSizable];
446 - (void)setIdentifier:(
id)anIdentifier
448 _identifier = anIdentifier;
464 - (void)setEditable:(BOOL)shouldBeEditable
466 _isEditable = shouldBeEditable;
483 _sortDescriptorPrototype = aSortDescriptor;
491 if (_sortDescriptorPrototype)
492 return _sortDescriptorPrototype;
494 var binderClass = [[
self class] _binderClassForBinding:CPValueBinding],
495 binding = [binderClass getBinding:CPValueBinding forObject:self];
497 return [binding _defaultSortDescriptorPrototype];
504 - (void)setHidden:(BOOL)shouldBeHidden
506 shouldBeHidden = !!shouldBeHidden
508 if (_isHidden === shouldBeHidden)
511 _isHidden = shouldBeHidden;
514 [[
self tableView] _tableColumnVisibilityDidChange:self];
533 _headerToolTip = aToolTip;
541 return _headerToolTip;
547 - (void)_postDidResizeNotificationWithOldWidth:(
float)oldWidth
549 [[
self tableView] _didResizeTableColumn:self];
566 column = [[tableView tableColumns] indexOfObjectIdenticalTo:_source],
570 [tableView reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes];
575 if (![
self createsSortDescriptor])
578 var keyPath = [_info objectForKey:CPObservedKeyPathKey],
579 dotIndex = keyPath.indexOf(
".");
584 var firstPart = keyPath.substring(0, dotIndex),
585 key = keyPath.substring(dotIndex + 1);
590 - (BOOL)createsSortDescriptor
592 var options = [_info objectForKey:CPOptionsKey],
593 optionValue = [options objectForKey:CPCreatesSortDescriptorBindingOption];
594 return optionValue === nil ? YES : [optionValue boolValue];
601 + (id)_binderClassForBinding:(
CPString)aBinding
606 return [
super _binderClassForBinding:aBinding];
621 if (![aBinding
isEqual:
@"someListOfExceptedBindings(notAcceptedBindings)"])
627 var acIndex = aKeyPath.lastIndexOf(
"arrangedObjects."),
628 arrayController = anObject;
632 var firstPart = aKeyPath.substring(0, acIndex - 1);
633 arrayController = [anObject valueForKeyPath:firstPart];
636 [[
self tableView] _establishBindingsIfUnbound:arrayController];
643 - (void)_prepareDataView:(
CPView)aDataView forRow:(
unsigned)aRow
646 keys = [bindingsDictionary allKeys];
648 for (var i = 0, count = [keys count]; i < count; i++)
650 var bindingName = keys[i],
651 bindingPath = [aDataView _replacementKeyPathForBinding:bindingName],
652 binding = [bindingsDictionary objectForKey:bindingName],
653 bindingInfo = binding._info,
654 destination = [bindingInfo objectForKey:CPObservedObjectKey],
655 keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
656 dotIndex = keyPath.lastIndexOf(
"."),
660 value = [[destination valueForKeyPath:keyPath] objectAtIndex:aRow];
674 var firstPart = keyPath.substring(0, dotIndex),
675 secondPart = keyPath.substring(dotIndex + 1),
676 firstValue = [destination valueForKeyPath:firstPart];
678 if ([firstValue isKindOfClass:
CPArray])
679 value = [[firstValue objectAtIndex:aRow] valueForKeyPath:secondPart];
681 value = [[firstValue valueForKeyPath:secondPart] objectAtIndex:aRow];
684 value = [binding transformValue:value withOptions:[bindingInfo objectForKey:CPOptionsKey]];
692 - (void)_reverseSetDataView:(
CPView)aDataView forRow:(
unsigned)aRow
695 keys = [bindingsDictionary allKeys],
698 for (var i = 0, count = [keys count]; i < count; i++)
700 var bindingName = keys[i],
701 bindingPath = [aDataView _replacementKeyPathForBinding:bindingName],
702 binding = [bindingsDictionary objectForKey:bindingName],
703 bindingInfo = binding._info,
704 destination = [bindingInfo objectForKey:CPObservedObjectKey],
705 keyPath = [bindingInfo objectForKey:CPObservedKeyPathKey],
706 options = [bindingInfo objectForKey:CPOptionsKey],
707 dotIndex = keyPath.lastIndexOf(
".");
709 newValue = [binding reverseTransformValue:newValue withOptions:options];
712 [[destination valueForKeyPath:keyPath] replaceObjectAtIndex:aRow withObject:newValue];
715 var firstPart = keyPath.substring(0, dotIndex),
716 secondPart = keyPath.substring(dotIndex + 1),
717 firstValue = [destination valueForKeyPath:firstPart];
719 if ([firstValue isKindOfClass:
CPArray])
720 [[firstValue objectAtIndex:aRow] setValue:newValue forKeyPath:secondPart];
722 [[firstValue valueForKeyPath:secondPart] replaceObjectAtIndex:aRow withObject:newValue];
753 _width = [aCoder decodeFloatForKey:CPTableColumnWidthKey];
754 _minWidth = [aCoder decodeFloatForKey:CPTableColumnMinWidthKey];
755 _maxWidth = [aCoder decodeFloatForKey:CPTableColumnMaxWidthKey];
757 [
self setIdentifier:[aCoder decodeObjectForKey:CPTableColumnIdentifierKey]];
758 [
self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
759 [
self setDataView:[aCoder decodeObjectForKey:CPTableColumnDataViewKey]];
761 _resizingMask = [aCoder decodeIntForKey:CPTableColumnResizingMaskKey];
762 _isHidden = [aCoder decodeBoolForKey:CPTableColumnIsHiddenKey];
763 _isEditable = [aCoder decodeBoolForKey:CPTableColumnIsEditableKey];
765 _sortDescriptorPrototype = [aCoder decodeObjectForKey:CPSortDescriptorPrototypeKey];
776 [aCoder encodeObject:_identifier forKey:CPTableColumnIdentifierKey];
778 [aCoder encodeFloat:_width forKey:CPTableColumnWidthKey];
779 [aCoder encodeFloat:_minWidth forKey:CPTableColumnMinWidthKey];
780 [aCoder encodeFloat:_maxWidth forKey:CPTableColumnMaxWidthKey];
782 [aCoder encodeObject:_headerView forKey:CPTableColumnHeaderViewKey];
783 [aCoder encodeObject:_dataView forKey:CPTableColumnDataViewKey];
785 [aCoder encodeObject:_resizingMask forKey:CPTableColumnResizingMaskKey];
786 [aCoder encodeBool:_isHidden forKey:CPTableColumnIsHiddenKey];
787 [aCoder encodeBool:_isEditable forKey:CPTableColumnIsEditableKey];
789 [aCoder encodeObject:_sortDescriptorPrototype forKey:CPSortDescriptorPrototypeKey];
801 reason:@"setHeaderCell: is not supported. Use -setHeaderView:aView instead."];
810 reason:@"headCell is not supported. Use -headerView instead."];
819 reason:@"setDataCell: is not supported. Use -setDataView:aView instead."];
828 reason:@"dataCell is not supported. Use -dataView instead."];
834 - (id)dataCellForRow:(
int)row
837 reason:@"dataCellForRow: is not supported. Use -dataViewForRow:row instead."];
847 - (BOOL)disableResizingPosting
849 return _disableResizingPosting;
855 - (void)setDisableResizingPosting:(BOOL)aValue
857 _disableResizingPosting = aValue;