mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:00:48 +00:00
Fixes to NSText.m and debugging information in NSCell.m and NSTextField.m.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4453 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
019319e44a
commit
41717267ec
4 changed files with 111 additions and 42 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
1999-06-21 Michael Hanni <mhanni@sprintmail.com>
|
||||||
|
|
||||||
|
* Source/NSText.m: a bunch of little tweaks. Will document today.
|
||||||
|
However as a consequence hitting return in Edit.app properly
|
||||||
|
moves lines down whereas before it lost lines.
|
||||||
|
* Source/NSCell.m: - editWithFrame:inView:editor:delegate:event:
|
||||||
|
Now puts fieldEditor in windows contentView rather than in the
|
||||||
|
cell. Debugging messages and red cell splash kept in for the
|
||||||
|
moment as debugging of NSTextField* continues.
|
||||||
|
|
||||||
1999-06-20 Michael Hanni <mhanni@sprintmail.com>
|
1999-06-20 Michael Hanni <mhanni@sprintmail.com>
|
||||||
|
|
||||||
* Images/common_TabSelectedLeft.tiff
|
* Images/common_TabSelectedLeft.tiff
|
||||||
|
|
|
@ -427,17 +427,40 @@ static Class imageClass;
|
||||||
delegate: (id)anObject
|
delegate: (id)anObject
|
||||||
event: (NSEvent *)theEvent
|
event: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
NSRect bRect;
|
||||||
|
|
||||||
if (cell_type != NSTextCellType)
|
if (cell_type != NSTextCellType)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[controlView lockFocus];
|
[controlView lockFocus];
|
||||||
[[controlView window] makeFirstResponder: textObject];
|
[[controlView window] makeFirstResponder: textObject];
|
||||||
|
|
||||||
[textObject setText: [self stringValue]];
|
bRect = [controlView convertRect:aRect toView:[[controlView window] contentView]];
|
||||||
|
// cellFrame.origin = [super_view convertPoint: frame.origin
|
||||||
|
// toView: [window contentView]];
|
||||||
|
|
||||||
|
NSLog(@"editWithFrame: aRect. x = %d, y = %d, width = %d, height = %d\n",
|
||||||
|
(int)aRect.origin.x,
|
||||||
|
(int)aRect.origin.y,
|
||||||
|
(int)aRect.size.width,
|
||||||
|
(int)aRect.size.height);
|
||||||
|
|
||||||
|
NSLog(@"editWithFrame: bRect. x = %d, y = %d, width = %d, height = %d\n",
|
||||||
|
(int)bRect.origin.x,
|
||||||
|
(int)bRect.origin.y,
|
||||||
|
(int)bRect.size.width,
|
||||||
|
(int)bRect.size.height);
|
||||||
|
|
||||||
[textObject setDelegate: anObject];
|
[textObject setDelegate: anObject];
|
||||||
[controlView addSubview: textObject];
|
|
||||||
[textObject setFrame: aRect];
|
[textObject setFrame: bRect];
|
||||||
NSEraseRect(aRect);
|
[[NSColor redColor] set];
|
||||||
|
NSRectFill(aRect);
|
||||||
|
// NSEraseRect(aRect);
|
||||||
|
|
||||||
|
[textObject setText: [self stringValue]];
|
||||||
|
|
||||||
|
[[[controlView window] contentView] addSubview: textObject];
|
||||||
[textObject display];
|
[textObject display];
|
||||||
[controlView unlockFocus];
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
|
@ -451,6 +474,7 @@ static Class imageClass;
|
||||||
[textObject setDelegate: nil];
|
[textObject setDelegate: nil];
|
||||||
[textObject removeFromSuperview];
|
[textObject removeFromSuperview];
|
||||||
[self setStringValue: [textObject text]];
|
[self setStringValue: [textObject text]];
|
||||||
|
[textObject setString:@""];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) selectWithFrame: (NSRect)aRect
|
- (void) selectWithFrame: (NSRect)aRect
|
||||||
|
|
107
Source/NSText.m
107
Source/NSText.m
|
@ -619,10 +619,12 @@ typedef enum
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) replaceRange:(NSRange)range withString:(NSString*) aString
|
-(void) replaceRange:(NSRange)range withString:(NSString*) aString
|
||||||
{ if([self isRichText])
|
{
|
||||||
{ return [rtfContent replaceCharactersInRange:range withString:aString];
|
if([self isRichText])
|
||||||
} else return [plainContent replaceCharactersInRange:range withString:aString];
|
{ return [rtfContent replaceCharactersInRange:range
|
||||||
}
|
withString:aString];
|
||||||
|
} else return [plainContent replaceCharactersInRange:range
|
||||||
|
withString:aString]; }
|
||||||
|
|
||||||
-(void) setText:(NSString*) aString range:(NSRange) aRange
|
-(void) setText:(NSString*) aString range:(NSRange) aRange
|
||||||
{ [self replaceRange:(NSRange)aRange withString:aString];
|
{ [self replaceRange:(NSRange)aRange withString:aString];
|
||||||
|
@ -641,10 +643,13 @@ typedef enum
|
||||||
-(void) setString:(NSString *)string
|
-(void) setString:(NSString *)string
|
||||||
{ [plainContent release];
|
{ [plainContent release];
|
||||||
plainContent=[[NSMutableString stringWithString:string] retain];
|
plainContent=[[NSMutableString stringWithString:string] retain];
|
||||||
[lineLayoutInformation autorelease]; lineLayoutInformation=nil; // force complete re-layout
|
[lineLayoutInformation autorelease];
|
||||||
|
lineLayoutInformation=nil;
|
||||||
|
// force complete re-layout
|
||||||
|
// [self setSelectedRange:NSMakeRange(0, [default_font widthOfString:string])];
|
||||||
|
NSLog(@"setSelectedRange called in setString\n");
|
||||||
|
[self setSelectedRange:NSMakeRange(0, 0)];
|
||||||
[self setRichText:NO];
|
[self setRichText:NO];
|
||||||
|
|
||||||
//[self setNeedsDisplay: YES];
|
|
||||||
}
|
}
|
||||||
-(void) setText:(NSString *)string {[self setString:string];}
|
-(void) setText:(NSString *)string {[self setString:string];}
|
||||||
|
|
||||||
|
@ -687,11 +692,16 @@ typedef enum
|
||||||
-(void) setRichText:(BOOL)flag
|
-(void) setRichText:(BOOL)flag
|
||||||
{ is_rich_text = flag;
|
{ is_rich_text = flag;
|
||||||
if(flag)
|
if(flag)
|
||||||
{ if(!rtfContent) rtfContent=[[NSMutableAttributedString alloc] initWithString:plainContent? (NSString*)plainContent:@"" attributes:[self defaultTypingAttributes]];
|
{
|
||||||
[self rebuildRichLineLayoutInformationStartingAtLine:0];
|
if(!rtfContent) {
|
||||||
} else
|
rtfContent=[[NSMutableAttributedString alloc] initWithString:plainContent? (NSString*)plainContent:@"" attributes:[self defaultTypingAttributes]];
|
||||||
{ if(!plainContent) plainContent=[[NSMutableString alloc] initWithString:rtfContent? [rtfContent string]:@""];
|
}
|
||||||
[self rebuildPlainLineLayoutInformationStartingAtLine:0];
|
[self rebuildRichLineLayoutInformationStartingAtLine:0];
|
||||||
|
} else {
|
||||||
|
if(!plainContent) {
|
||||||
|
plainContent=[[NSMutableString alloc] initWithString:rtfContent? [rtfContent string]:@""];
|
||||||
|
}
|
||||||
|
[self rebuildPlainLineLayoutInformationStartingAtLine:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self updateDragTypeRegistration];
|
[self updateDragTypeRegistration];
|
||||||
|
@ -846,6 +856,12 @@ typedef enum
|
||||||
-(void) setSelectedRange:(NSRange)range
|
-(void) setSelectedRange:(NSRange)range
|
||||||
{ BOOL didLock=NO;
|
{ BOOL didLock=NO;
|
||||||
|
|
||||||
|
NSLog(@"setSelectedRange:\n\tcurrentrange location = %d, length = %d. wantedrange location = %d, length = %d\n",
|
||||||
|
(int)selected_range.location,
|
||||||
|
(int)selected_range.length,
|
||||||
|
(int)range.location,
|
||||||
|
(int)range.length);
|
||||||
|
|
||||||
if(![self window])
|
if(![self window])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -890,12 +906,10 @@ typedef enum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sizing the Frame Rectangle
|
// Sizing the Frame Rectangle
|
||||||
//
|
//
|
||||||
-(void) setFrame:(NSRect)frameRect
|
|
||||||
{ [super setFrame:frameRect];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(BOOL) isHorizontallyResizable { return is_horizontally_resizable; }
|
-(BOOL) isHorizontallyResizable { return is_horizontally_resizable; }
|
||||||
-(BOOL) isVerticallyResizable { return is_vertically_resizable; }
|
-(BOOL) isVerticallyResizable { return is_vertically_resizable; }
|
||||||
|
@ -937,8 +951,16 @@ typedef enum
|
||||||
-(void) disableDisplay {displayDisabled=YES;}
|
-(void) disableDisplay {displayDisabled=YES;}
|
||||||
-(void) reenableDisplay {displayDisabled=NO;}
|
-(void) reenableDisplay {displayDisabled=NO;}
|
||||||
|
|
||||||
|
-(void) setFrame:(NSRect)frameRect
|
||||||
|
{
|
||||||
|
[super setFrame:frameRect];
|
||||||
|
[self sizeToFit];
|
||||||
|
}
|
||||||
|
|
||||||
-(void) sizeToFit
|
-(void) sizeToFit
|
||||||
{ NSRect sizeToRect=[self frame];
|
{
|
||||||
|
/*
|
||||||
|
NSRect sizeToRect=[self frame];
|
||||||
if([self isHorizontallyResizable])
|
if([self isHorizontallyResizable])
|
||||||
{ if([lineLayoutInformation count])
|
{ if([lineLayoutInformation count])
|
||||||
{ sizeToRect=[self boundingRectForLineRange:NSMakeRange(0,[lineLayoutInformation count])];
|
{ sizeToRect=[self boundingRectForLineRange:NSMakeRange(0,[lineLayoutInformation count])];
|
||||||
|
@ -960,6 +982,7 @@ typedef enum
|
||||||
if(!NSEqualSizes([self frame].size,sizeToRect.size))
|
if(!NSEqualSizes([self frame].size,sizeToRect.size))
|
||||||
{ [self setFrame:sizeToRect]; //[self setFrameSize:sizeToRect.size];
|
{ [self setFrame:sizeToRect]; //[self setFrameSize:sizeToRect.size];
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
-(void) sizeToFit:sender {[self sizeToFit];}
|
-(void) sizeToFit:sender {[self sizeToFit];}
|
||||||
|
|
||||||
|
@ -1181,6 +1204,8 @@ typedef enum
|
||||||
|
|
||||||
didDragging=YES;
|
didDragging=YES;
|
||||||
}
|
}
|
||||||
|
NSLog(@"chosenRange. location = % d, length = %d\n",
|
||||||
|
(int)chosenRange.location, (int)chosenRange.length);
|
||||||
[self setSelectedRangeNoDrawing:chosenRange];
|
[self setSelectedRangeNoDrawing:chosenRange];
|
||||||
if(!didDragging) [self drawSelectionAsRange:chosenRange];
|
if(!didDragging) [self drawSelectionAsRange:chosenRange];
|
||||||
else if(chosenRange.length== 0) [self drawInsertionPointAtIndex:chosenRange.location color:[NSColor blackColor] turnedOn:YES];
|
else if(chosenRange.length== 0) [self drawInsertionPointAtIndex:chosenRange.location color:[NSColor blackColor] turnedOn:YES];
|
||||||
|
@ -1850,26 +1875,27 @@ static unsigned _relocLayoutArray(NSMutableArray *lineLayoutInformation,NSArray
|
||||||
// <!> detachNewThreadSelector:selector toTarget:target withObject:argument;
|
// <!> detachNewThreadSelector:selector toTarget:target withObject:argument;
|
||||||
|
|
||||||
-(int) rebuildPlainLineLayoutInformationStartingAtLine:(int) aLine delta:(int) insertionDelta actualLine:(int) insertionLineIndex
|
-(int) rebuildPlainLineLayoutInformationStartingAtLine:(int) aLine delta:(int) insertionDelta actualLine:(int) insertionLineIndex
|
||||||
{ NSDictionary *attributes=[self defaultTypingAttributes];
|
{ NSDictionary *attributes=[self defaultTypingAttributes];
|
||||||
NSPoint drawingPoint=NSZeroPoint;
|
NSPoint drawingPoint=NSZeroPoint;
|
||||||
_GNUTextScanner *parscanner;
|
_GNUTextScanner *parscanner;
|
||||||
float width=[self frame].size.width;
|
float width=[self frame].size.width;
|
||||||
unsigned startingIndex=0,currentLineIndex;
|
unsigned startingIndex=0,currentLineIndex;
|
||||||
_GNULineLayoutInfo *lastValidLineInfo=nil;
|
_GNULineLayoutInfo *lastValidLineInfo=nil;
|
||||||
NSArray *ghostArray=nil; // for optimization detection
|
NSArray *ghostArray=nil; // for optimization detection
|
||||||
_GNUSeekableArrayEnumerator *prevArrayEnum=nil;
|
_GNUSeekableArrayEnumerator *prevArrayEnum=nil;
|
||||||
NSCharacterSet *invSelectionWordGranularitySet=[selectionWordGranularitySet invertedSet];
|
NSCharacterSet *invSelectionWordGranularitySet=[selectionWordGranularitySet invertedSet];
|
||||||
NSCharacterSet *invSelectionParagraphGranularitySet=[selectionParagraphGranularitySet invertedSet];
|
NSCharacterSet *invSelectionParagraphGranularitySet=[selectionParagraphGranularitySet invertedSet];
|
||||||
NSString *parsedString;
|
NSString *parsedString;
|
||||||
BOOL isHorizontallyResizable=[self isHorizontallyResizable];
|
BOOL isHorizontallyResizable=[self isHorizontallyResizable];
|
||||||
int lineDriftOffset=0,rebuildLineDrift=0;
|
int lineDriftOffset=0,rebuildLineDrift=0;
|
||||||
BOOL frameshiftCorrection=NO,nlDidShift=NO,enforceOpti=NO;
|
BOOL frameshiftCorrection=NO,nlDidShift=NO,enforceOpti=NO;
|
||||||
float yDisplacement=0;
|
float yDisplacement=0;
|
||||||
BOOL isRich=[self isRichText];
|
BOOL isRich=[self isRichText];
|
||||||
|
|
||||||
if(!lineLayoutInformation) lineLayoutInformation=[[NSMutableArray alloc] init];
|
if(!lineLayoutInformation) {
|
||||||
else
|
NSLog(@"lineLayoutInformation was just created.\n");
|
||||||
{
|
lineLayoutInformation=[[NSMutableArray alloc] init];
|
||||||
|
} else {
|
||||||
NSLog(@"aLine = %d, count = %d\n", (int)aLine,
|
NSLog(@"aLine = %d, count = %d\n", (int)aLine,
|
||||||
(int)[lineLayoutInformation count]);
|
(int)[lineLayoutInformation count]);
|
||||||
|
|
||||||
|
@ -2110,7 +2136,10 @@ NSLog(@"opti hook 2");
|
||||||
{ if([self isRichText])
|
{ if([self isRichText])
|
||||||
{ return [self rebuildRichLineLayoutInformationStartingAtLine:0 delta:0 actualLine:0];
|
{ return [self rebuildRichLineLayoutInformationStartingAtLine:0 delta:0 actualLine:0];
|
||||||
} else
|
} else
|
||||||
{ return [self rebuildPlainLineLayoutInformationStartingAtLine:0 delta:0 actualLine:0];
|
{
|
||||||
|
NSLog(@"- rebuildLineLayout atLine = %d\n", aLine);
|
||||||
|
return [self rebuildPlainLineLayoutInformationStartingAtLine:0
|
||||||
|
delta:0 actualLine:0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2177,6 +2206,12 @@ NSLog(@"opti hook 2");
|
||||||
-(void) drawRect:(NSRect)rect
|
-(void) drawRect:(NSRect)rect
|
||||||
{ if(displayDisabled) return;
|
{ if(displayDisabled) return;
|
||||||
|
|
||||||
|
NSLog(@"- drawRect: in NSText. x = %d, y = %d, width = %d, height = %d\n",
|
||||||
|
(int)rect.origin.x,
|
||||||
|
(int)rect.origin.y,
|
||||||
|
(int)rect.size.width,
|
||||||
|
(int)rect.size.height);
|
||||||
|
|
||||||
[self drawRectNoSelection:rect];
|
[self drawRectNoSelection:rect];
|
||||||
[self drawSelectionAsRange:[self selectedRange]];
|
[self drawSelectionAsRange:[self selectedRange]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,8 +305,8 @@ fprintf(stderr, " TextField mouseDown --- ");
|
||||||
// location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
|
// location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
|
||||||
// [self lockFocus];
|
// [self lockFocus];
|
||||||
// cellFrame = [self convertRect: frame toView: nil];
|
// cellFrame = [self convertRect: frame toView: nil];
|
||||||
// cellFrame.origin = [super_view convertPoint: frame.origin
|
// cellFrame.origin = [super_view convertPoint: frame.origin
|
||||||
// toView: [window contentView]];
|
// toView: [window contentView]];
|
||||||
|
|
||||||
if ([cell isBordered])
|
if ([cell isBordered])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue