diff --git a/ChangeLog b/ChangeLog index 6f38dec11..8c2dc3ec6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2009-12-17 Wolfgang Lux + + * Source/NSCell.m (-wraps, -setWraps:, -setLineBreakMode:, + -initWithCoder:): Phase out the wraps cell attribute since it is + implied by the lineBreakMode attribute. Note that with this change + cells now wrap by default, as has always been the case on OS X. + + * Source/NSBrowserCell.m (-initTextCell:, -initImageCell:): + * Source/NSTableColumn.m (-initWithIdentifier): Set default line + break mode to NSLineBreakByTruncatingTail as on OS X. + + * Source/NSCell.m (-setUpFieldEditorAttributes:): Set the typing + attributes of the field editor so that it uses the same paragraph + style and in particular the same line break mode as the edited + cell. This fixes an inconsistency where wrapped text would be + displayed in a single line during editing. + 2009-12-17 Wolfgang Lux * Source/NSCell.m (-_setupTextWithFrame:inView:editor:delegate:range): diff --git a/Headers/AppKit/NSCell.h b/Headers/AppKit/NSCell.h index 0012939b1..167aa9ed6 100644 --- a/Headers/AppKit/NSCell.h +++ b/Headers/AppKit/NSCell.h @@ -140,7 +140,7 @@ enum { unsigned is_bordered: 1; unsigned is_bezeled: 1; unsigned is_scrollable: 1; - unsigned wraps: 1; + unsigned reserved: 1; unsigned text_align: 3; // 5 values unsigned is_selectable: 1; unsigned allows_mixed_state: 1; diff --git a/Source/NSBrowserCell.m b/Source/NSBrowserCell.m index 2b99da05f..529518b31 100644 --- a/Source/NSBrowserCell.m +++ b/Source/NSBrowserCell.m @@ -109,6 +109,7 @@ static NSFont *_leafFont; //_alternateImage = nil; //_browsercell_is_leaf = NO; //_browsercell_is_loaded = NO; + [self setLineBreakMode: NSLineBreakByTruncatingTail]; if (_gsFontifyCells) [self setFont: _nonLeafFont]; @@ -122,6 +123,7 @@ static NSFont *_leafFont; //_alternateImage = nil; //_browsercell_is_leaf = NO; //_browsercell_is_loaded = NO; + [self setLineBreakMode: NSLineBreakByTruncatingTail]; if (_gsFontifyCells) [self setFont: _nonLeafFont]; diff --git a/Source/NSCell.m b/Source/NSCell.m index 45033c643..9c9c7749b 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -173,6 +173,7 @@ static NSColor *dtxtCol; //_cell.is_scrollable = NO; //_cell.is_selectable = NO; //_cell.state = 0; + //_cell.line_break_mode = NSLineBreakByWordWrapping; _action_mask = NSLeftMouseUpMask; _menu = [isa defaultMenu]; [self setFocusRingType: [isa defaultFocusRingType]]; @@ -203,6 +204,7 @@ static NSColor *dtxtCol; //_cell.is_bezeled = NO; //_cell.is_scrollable = NO; //_cell.is_selectable = NO; + //_cell.line_break_mode = NSLineBreakByWordWrapping; _action_mask = NSLeftMouseUpMask; _menu = [isa defaultMenu]; [self setFocusRingType: [isa defaultFocusRingType]]; @@ -935,22 +937,22 @@ static NSColor *dtxtCol; - (void) setWraps: (BOOL)flag { - _cell.wraps = flag; - if (flag) { - _cell.is_scrollable = NO; - [self setLineBreakMode: NSLineBreakByWordWrapping]; + if (![self wraps]) + [self setLineBreakMode: NSLineBreakByWordWrapping]; } else { - [self setLineBreakMode: NSLineBreakByClipping]; + if ([self wraps]) + [self setLineBreakMode: NSLineBreakByClipping]; } } - (BOOL) wraps { - return _cell.wraps; + return _cell.line_break_mode == NSLineBreakByWordWrapping + || _cell.line_break_mode == NSLineBreakByCharWrapping; } - (void) setAttributedStringValue: (NSAttributedString*)attribStr @@ -1056,6 +1058,10 @@ static NSColor *dtxtCol; - (void) setLineBreakMode: (NSLineBreakMode)mode { + if (mode == NSLineBreakByCharWrapping || mode == NSLineBreakByWordWrapping) + { + _cell.is_scrollable = NO; + } _cell.line_break_mode = mode; } @@ -2098,6 +2104,9 @@ static NSColor *dtxtCol; [textObject setRichText: [self allowsEditingTextAttributes]]; [textObject setImportsGraphics: [self importsGraphics]]; [(NSTextView*)textObject setAllowsUndo: [self allowsUndo]]; + NSDictionary *attr = [self _nonAutoreleasedTypingAttributes]; + [(NSTextView*)textObject setTypingAttributes: attr]; + RELEASE(attr); return textObject; } @@ -2534,7 +2543,7 @@ static NSColor *dtxtCol; } else { - BOOL flag; + BOOL flag, wraps; unsigned int tmp_int; id formatter, menu; int version = [aDecoder versionForClassName: @"NSCell"]; @@ -2575,7 +2584,9 @@ static NSColor *dtxtCol; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _cell.allows_mixed_state = flag; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; - _cell.wraps = flag; + /* The wraps attribute has been superseded by lineBreakMode. However, + we may need it to set lineBreakMode when reading old archives. */ + wraps = flag; [aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; _cell.text_align = tmp_int; [aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; @@ -2717,6 +2728,12 @@ static NSColor *dtxtCol; [aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int]; _cell.base_writing_direction = tmp_int; } + else + { + /* Backward compatibility: Derive lineBreakMode from the superseded + wraps attribute. */ + [self setWraps: wraps]; + } } return self; } diff --git a/Source/NSTableColumn.m b/Source/NSTableColumn.m index 8b1a5f832..542145df1 100644 --- a/Source/NSTableColumn.m +++ b/Source/NSTableColumn.m @@ -114,6 +114,7 @@ _headerCell = [NSTableHeaderCell new]; _dataCell = [NSTextFieldCell new]; + [_dataCell setLineBreakMode: NSLineBreakByTruncatingTail]; _headerToolTip = nil; _sortDescriptorPrototype = nil;