Patches partly by Andreas Höschler <ahoesch@smartsoft.de>.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25476 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2007-09-11 12:13:35 +00:00
parent 83dba0e1a3
commit 339e3acbef
3 changed files with 66 additions and 36 deletions

View file

@ -1,3 +1,13 @@
2007-09-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m (-drawRect:, -rectForCharacterRange:,
-firstRectForCharacterRange:): Protect againt layoutmanager being nil.
* Source/NSTableView.m (-validateEditing): Use setStringValue:
when converting the string failed.
* Source/NSTableView.m (-mouseDown:): Don't interrupt editing
another cell, if the current string isn't valid.
Patches partly by Andreas Höschler <ahoesch@smartsoft.de>.
2007-09-10 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPopUpButtonCell.m (-insertItemWithTitle:atIndex:):

View file

@ -3160,45 +3160,13 @@ byExtendingSelection: (BOOL)flag
formatter = [_editedCell formatter];
string = AUTORELEASE([[_textObject text] copy]);
if (formatter == nil)
{
newObjectValue = string;
}
else
if (formatter != nil)
{
NSString *error;
if ([formatter getObjectValue: &newObjectValue
forString: string
errorDescription: &error] == NO)
{
if ([_delegate respondsToSelector:
@selector(control:didFailToFormatString:errorDescription:)])
{
if ([_delegate control: self
didFailToFormatString: string
errorDescription: error] == NO)
{
validatedOK = NO;
}
else
{
newObjectValue = string;
}
}
// Allow an empty string to fall through
else if ([string isEqualToString: @""])
{
newObjectValue = string;
}
else
{
validatedOK = NO;
}
}
}
if (validatedOK == YES)
errorDescription: &error] == YES)
{
[_editedCell setObjectValue: newObjectValue];
@ -3211,9 +3179,40 @@ byExtendingSelection: (BOOL)flag
[self _setObjectValue: newObjectValue
forTableColumn: tb
row: _editedRow];
}
return;
}
else
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:);
//[_dataSource tableView: self setObjectValue: newObjectValue
// forTableColumn: tb row: _editedRow];
if ([_delegate respondsToSelector: sel])
{
validatedOK = [_delegate control: self
didFailToFormatString: string
errorDescription: error];
}
// Allow an empty string to fall through
else if (![string isEqualToString: @""])
{
validatedOK = NO;
}
}
}
if (validatedOK)
{
[_editedCell setStringValue: string];
if (_dataSource_editable)
{
NSTableColumn *tb;
tb = [_tableColumns objectAtIndex: _editedColumn];
[self _setObjectValue: string
forTableColumn: tb
row: _editedRow];
}
}
}
@ -3485,6 +3484,12 @@ static inline float computePeriod(NSPoint mouseLocationWin,
/* Stop editing if any */
if (_textObject != nil)
{
if (_editedCell != nil
&& [_editedCell isEntryAcceptable:[_textObject text]] == NO)
{
NSBeep();
return;
}
[self validateEditing];
[self abortEditing];
}

View file

@ -1856,8 +1856,13 @@ or add guards
- (NSRect) firstRectForCharacterRange: (NSRange)theRange
{
unsigned int rectCount = 0; /* If there's no layout manager, it'll be 0 after the call too. */
NSRect *rects = [_layoutManager
unsigned int rectCount = 0;
NSRect *rects;
if (!_layoutManager)
return NSZeroRect;
rects = [_layoutManager
rectArrayForCharacterRange: theRange
withinSelectedCharacterRange: NSMakeRange(NSNotFound, 0)
inTextContainer: _textContainer
@ -2509,6 +2514,9 @@ Scroll so that the beginning of the range is visible.
*/
[self sizeToFit];
if (_layoutManager == nil)
return;
if (aRange.length > 0)
{
aRange.length = 1;
@ -2860,7 +2868,7 @@ This method is for user changes; see NSTextView_actions.m.
- (void) updateFontPanel
{
/* Update fontPanel only if told so */
if (_tf.uses_font_panel)
if (_tf.uses_font_panel && _layoutManager)
{
NSRange longestRange;
NSFontManager *fm = [NSFontManager sharedFontManager];
@ -3325,8 +3333,15 @@ Figure out how the additional layout stuff is supposed to work.
containerRect.origin.x -= _textContainerOrigin.x;
containerRect.origin.y -= _textContainerOrigin.y;
if (_layoutManager)
{
drawnRange = [_layoutManager glyphRangeForBoundingRect: containerRect
inTextContainer: _textContainer];
}
else
{
drawnRange = NSMakeRange(0, 0);
}
if (_tf.draws_background)
{
@ -4716,7 +4731,7 @@ configuation! */
NSRange glyphRange;
NSRect rect;
if (!aRange.length)
if (!aRange.length || !_layoutManager)
return NSZeroRect;
glyphRange = [_layoutManager glyphRangeForCharacterRange: aRange
actualCharacterRange: NULL];