Diverse gui patches by Wolfgang Lux <wolfgang.lux@gmail.com>.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25451 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2007-09-04 23:29:05 +00:00
parent 347b646c1d
commit 9a371e74bd
4 changed files with 165 additions and 126 deletions

View file

@ -1582,6 +1582,7 @@ void NSBeginInformationalAlertSheet(NSString *title,
{ {
GSAlertPanel *panel; GSAlertPanel *panel;
NSString *title; NSString *title;
unsigned nbut = [_buttons count];
panel = [[GSAlertPanel alloc] init]; panel = [[GSAlertPanel alloc] init];
_window = panel; _window = panel;
@ -1603,9 +1604,9 @@ void NSBeginInformationalAlertSheet(NSString *title,
icon: _icon icon: _icon
title: _informative_text title: _informative_text
message: _message_text message: _message_text
def: [[_buttons objectAtIndex: 0] title] def: (nbut > 0) ? [[_buttons objectAtIndex: 0] title] : (NSString*)nil
alt: [[_buttons objectAtIndex: 1] title] alt: (nbut > 1) ? [[_buttons objectAtIndex: 1] title] : (NSString*)nil
other: [[_buttons objectAtIndex: 2] title]]; other: (nbut > 2) ? [[_buttons objectAtIndex: 2] title] : (NSString*)nil];
} }
} }

View file

@ -233,7 +233,12 @@ withContentsOfURL: (NSURL *)url
{ {
[self setFileURL: [NSURL fileURLWithPath: fileName]]; [self setFileURL: [NSURL fileURLWithPath: fileName]];
} }
else
{
ASSIGN(_file_name, fileName); ASSIGN(_file_name, fileName);
ASSIGN(_file_url, [NSURL fileURLWithPath: fileName]);
[self setLastComponentOfFileName: [_file_name lastPathComponent]];
}
[self setLastComponentOfFileName: [_file_name lastPathComponent]]; [self setLastComponentOfFileName: [_file_name lastPathComponent]];
} }
@ -269,6 +274,7 @@ withContentsOfURL: (NSURL *)url
else else
{ {
ASSIGN(_file_url, url); ASSIGN(_file_url, url);
ASSIGN(_file_name, (url && [url isFileURL]) ? [url path] : (NSString*)nil);
[self setLastComponentOfFileName: [[_file_url path] lastPathComponent]]; [self setLastComponentOfFileName: [[_file_url path] lastPathComponent]];
} }
} }
@ -537,6 +543,7 @@ withContentsOfURL: (NSURL *)url
{ {
if (OVERRIDDEN(dataRepresentationOfType:)) if (OVERRIDDEN(dataRepresentationOfType:))
{ {
*error = nil;
return [self dataRepresentationOfType: type]; return [self dataRepresentationOfType: type];
} }
@ -569,6 +576,7 @@ withContentsOfURL: (NSURL *)url
if (OVERRIDDEN(fileWrapperRepresentationOfType:)) if (OVERRIDDEN(fileWrapperRepresentationOfType:))
{ {
*error = nil;
return [self fileWrapperRepresentationOfType: type]; return [self fileWrapperRepresentationOfType: type];
} }
@ -654,6 +662,7 @@ withContentsOfURL: (NSURL *)url
{ {
if (OVERRIDDEN(loadFileWrapperRepresentation:ofType:)) if (OVERRIDDEN(loadFileWrapperRepresentation:ofType:))
{ {
*error = nil;
return [self loadFileWrapperRepresentation: wrapper ofType: type]; return [self loadFileWrapperRepresentation: wrapper ofType: type];
} }
@ -665,6 +674,7 @@ withContentsOfURL: (NSURL *)url
} }
// FIXME: Set error // FIXME: Set error
*error = nil;
return NO; return NO;
} }
@ -678,6 +688,7 @@ withContentsOfURL: (NSURL *)url
if (OVERRIDDEN(readFromFile:ofType:)) if (OVERRIDDEN(readFromFile:ofType:))
{ {
*error = nil;
return [self readFromFile: [url path] ofType: type]; return [self readFromFile: [url path] ofType: type];
} }
else else
@ -691,6 +702,7 @@ withContentsOfURL: (NSURL *)url
} }
// FIXME: Set error // FIXME: Set error
*error = nil;
return NO; return NO;
} }
@ -821,6 +833,7 @@ withContentsOfURL: (NSURL *)url
saveOp = NSSaveToOperation; saveOp = NSSaveToOperation;
} }
*error = nil;
return [self writeWithBackupToFile: [url path] return [self writeWithBackupToFile: [url path]
ofType: type ofType: type
saveOperation: saveOp]; saveOperation: saveOp];
@ -828,6 +841,8 @@ withContentsOfURL: (NSURL *)url
if (!isNativeType || (url == nil)) if (!isNativeType || (url == nil))
{ {
// FIXME: Set error
*error = nil;
return NO; return NO;
} }
@ -846,6 +861,7 @@ withContentsOfURL: (NSURL *)url
toFile: backupFilename]) toFile: backupFilename])
{ {
// FIXME: Set error. // FIXME: Set error.
*error = nil;
return NO; return NO;
} }
} }
@ -891,6 +907,7 @@ withContentsOfURL: (NSURL *)url
if (OVERRIDDEN(writeToFile:ofType:)) if (OVERRIDDEN(writeToFile:ofType:))
{ {
*error = nil;
return [self writeToFile: [url path] ofType: type]; return [self writeToFile: [url path] ofType: type];
} }
@ -898,9 +915,12 @@ withContentsOfURL: (NSURL *)url
error: error]; error: error];
if (wrapper == nil) if (wrapper == nil)
{ {
// FIXME: Set error
*error = nil;
return NO; return NO;
} }
*error = nil;
return [wrapper writeToFile: [url path] atomically: YES updateFilenames: YES]; return [wrapper writeToFile: [url path] atomically: YES updateFilenames: YES];
} }
@ -914,6 +934,7 @@ originalContentsURL: (NSURL *)orig
{ {
if (saveOp == NSAutosaveOperation) if (saveOp == NSAutosaveOperation)
{ {
*error = nil;
saveOp = NSSaveToOperation; saveOp = NSSaveToOperation;
} }
@ -1249,6 +1270,7 @@ originalContentsURL: (NSURL *)orig
- (NSPrintOperation *)printOperationWithSettings: (NSDictionary *)settings - (NSPrintOperation *)printOperationWithSettings: (NSDictionary *)settings
error: (NSError **)error error: (NSError **)error
{ {
*error = nil;
return nil; return nil;
} }
@ -1363,6 +1385,7 @@ originalContentsURL: (NSURL *)orig
error:(NSError **)error error:(NSError **)error
{ {
// FIXME: Implement. Should set NSFileExtensionHidden // FIXME: Implement. Should set NSFileExtensionHidden
*error = nil;
return [NSDictionary dictionary]; return [NSDictionary dictionary];
} }

View file

@ -696,8 +696,9 @@ anything visible
last_visible = lf->pos; last_visible = lf->pos;
for (j = lp->pos - glyph_pos; j + glyph_pos < lp->pos + lp->length;) for (j = lp->pos - glyph_pos; j + glyph_pos < lp->pos + lp->length;)
{ {
if (r->glyphs[j].isNotShown || r->glyphs[j].g == NSControlGlyph || // Don't ignore invisble glyphs.
!r->glyphs[j].g) // if (r->glyphs[j].isNotShown || r->glyphs[j].g == NSControlGlyph ||
if (!r->glyphs[j].g)
{ {
GLYPH_STEP_FORWARD(r, j, glyph_pos, char_pos) GLYPH_STEP_FORWARD(r, j, glyph_pos, char_pos)
continue; continue;

View file

@ -1793,7 +1793,8 @@ here. */
TODO: make sure this is only called when _layoutManager is known non-nil, TODO: make sure this is only called when _layoutManager is known non-nil,
or add guards or add guards
*/ */
- (unsigned int) characterIndexForPoint: (NSPoint)point - (unsigned int) _characterIndexForPoint: (NSPoint)point
respectFraction: (BOOL)respectFraction
{ {
unsigned index; unsigned index;
float fraction; float fraction;
@ -1808,13 +1809,22 @@ or add guards
return (unsigned int)-1; return (unsigned int)-1;
index = [_layoutManager characterIndexForGlyphAtIndex: index]; index = [_layoutManager characterIndexForGlyphAtIndex: index];
if (fraction > 0.5 && index < [_textStorage length]) if (respectFraction && fraction > 0.5 && index < [_textStorage length] &&
[[_textStorage string] characterAtIndex:index] != '\n')
{ {
index++; index++;
} }
return index; return index;
} }
// This method takes screen coordinates as input.
- (unsigned int) characterIndexForPoint: (NSPoint)point
{
point = [[self window] convertScreenToBase: point];
point = [self convertPoint:point fromView: nil];
return [self _characterIndexForPoint: point respectFraction: NO];
}
- (NSRange) markedRange - (NSRange) markedRange
{ {
return NSMakeRange(NSNotFound, 0); return NSMakeRange(NSNotFound, 0);
@ -4267,7 +4277,8 @@ other than copy/paste or dragging. */
dragPoint = [sender draggingLocation]; dragPoint = [sender draggingLocation];
dragPoint = [self convertPoint: dragPoint fromView: nil]; dragPoint = [self convertPoint: dragPoint fromView: nil];
dragIndex = [self characterIndexForPoint: dragPoint]; dragIndex = [self _characterIndexForPoint: dragPoint
respectFraction: YES];
dragRange = NSMakeRange (dragIndex, 0); dragRange = NSMakeRange (dragIndex, 0);
range = [self selectionRangeForProposedRange: dragRange range = [self selectionRangeForProposedRange: dragRange
@ -4302,7 +4313,8 @@ other than copy/paste or dragging. */
dragPoint = [sender draggingLocation]; dragPoint = [sender draggingLocation];
dragPoint = [self convertPoint: dragPoint fromView: nil]; dragPoint = [self convertPoint: dragPoint fromView: nil];
dragIndex = [self characterIndexForPoint: dragPoint]; dragIndex = [self _characterIndexForPoint: dragPoint
respectFraction: YES];
dragRange = NSMakeRange (dragIndex, 0); dragRange = NSMakeRange (dragIndex, 0);
range = [self selectionRangeForProposedRange: dragRange range = [self selectionRangeForProposedRange: dragRange
@ -4416,7 +4428,8 @@ other than copy/paste or dragging. */
possible) */ possible) */
startPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil]; startPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil];
startIndex = [self characterIndexForPoint: startPoint]; startIndex = [self _characterIndexForPoint: startPoint
respectFraction: [theEvent clickCount] == 1];
if (startIndex == (unsigned int)-1) if (startIndex == (unsigned int)-1)
{ {
@ -4620,7 +4633,8 @@ other than copy/paste or dragging. */
point = [self convertPoint: [lastEvent locationInWindow] point = [self convertPoint: [lastEvent locationInWindow]
fromView: nil]; fromView: nil];
proposedRange = MakeRangeFromAbs([self characterIndexForPoint: point], proposedRange = MakeRangeFromAbs([self _characterIndexForPoint: point
respectFraction: YES],
startIndex); startIndex);
chosenRange = [self selectionRangeForProposedRange: proposedRange chosenRange = [self selectionRangeForProposedRange: proposedRange
granularity: granularity]; granularity: granularity];