* NSSplitView.m in drawRect moved NSRectFill() to backend

* NSSavePanel.m commented out call to NSRunAlertPanel
	* NSText.h and NSText.m integrated source from Daniel B�hringer.
	* NSTextView.h and NSTextView.m integrated source from Daniel B�hringer.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2936 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Felipe A. Rodriguez 1998-08-20 09:56:26 +00:00
parent 3c3d8b4aef
commit 2b9b066fcc
7 changed files with 258 additions and 105 deletions

View file

@ -1,4 +1,11 @@
<<<<<<< ChangeLog
Thurs Aug 20 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSSplitView.m in drawRect moved NSRectFill() to backend
* NSSavePanel.m commented out call to NSRunAlertPanel
* NSText.h and NSText.m integrated source from Daniel Bðhringer.
* NSTextView.h and NSTextView.m integrated source from Daniel Bðhringer.
Weds Aug 19 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSView.h added specific values and comments to resize constants enum.

View file

@ -100,49 +100,30 @@ typedef enum _NSSelectionAffinity
void *be_text_reserved; // Reserved for back-end use
NSSize minSize, maxSize;
NSDictionary *typingAttributes;
NSSize minSize, maxSize; // added for Daniel Bðhringer
// content
NSMutableString *plainContent;
NSMutableAttributedString *rtfContent;
// internal stuff
// contains private _GNULineLayoutInfo objects
NSMutableArray *lineLayoutInformation;
int spellCheckerDocumentTag;
NSCharacterSet *selectionWordGranularitySet;
NSCharacterSet *selectionWordGranularitySet;
NSCharacterSet *selectionParagraphGranularitySet;
NSCharacterSet *inWordSet, *outsideWordSet; // linewrapping by word
}
//
// GNU utility methods
//
// return value is guaranteed to be a
// NSAttributedString even if data is only NSString
+ (NSAttributedString*) attributedStringForData:(NSString*) aData;
+ (NSData*) dataForAttributedString:(NSAttributedString*) aString;
//
// Getting and Setting Contents
//
- (void)replaceRange:(NSRange)range
withRTF:(NSData *)rtfData;
- (void)replaceRange:(NSRange)range
withRTFD:(NSData *)rtfdData;
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString;
- (void)replaceCharactersInRange:(NSRange)range withRTF:(NSData *)rtfData;
- (void)replaceCharactersInRange:(NSRange)range withRTFD:(NSData *)rtfdData;
- (void)replaceRange:(NSRange)range withRTF:(NSData *)rtfData;
- (void)replaceRange:(NSRange)range withRTFD:(NSData *)rtfdData;
- (NSData *)RTFDFromRange:(NSRange)range;
- (NSData *)RTFFromRange:(NSRange)range;
- (void)setText:(NSString *)string;
- (void)setText:(NSString *)string
range:(NSRange)range;
- (void)setText:(NSString *)string range:(NSRange)range;
- (NSString *)text;
- (NSString *)string;
- (void)setString:(NSString *)string; // old fashioned
- (unsigned) textLength; // GNU extension
//
// Managing Global Characteristics
//

View file

@ -5,7 +5,7 @@
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into GNUstep
Source by Daniel Bðhringer integrated into GNUstep gui
by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
@ -32,16 +32,33 @@
@interface NSTextView : NSText
{
NSDictionary *typingAttributes;
int spellCheckerDocumentTag;
}
- (void)insertText:(NSString *)insertString;
- (NSDictionary*)typingAttributes;
- (void)setTypingAttributes:(NSDictionary *)attrs;
- (NSArray *)acceptableDragTypes;
- (void)updateDragTypeRegistration;
- (NSRange) selectionRangeForProposedRange:(NSRange)proposedCharRange
granularity:(NSSelectionGranularity)granularity;
- (int)spellCheckerDocumentTag;
//
// Managing the Selection NSText method
//
- (void)setSelectedRange:(NSRange)range;
//
// NSIgnoreMisspelledWords protocol
//
- (void)ignoreSpelling:(id)sender;
@end
#endif /* _GNUstep_H_NSTextView */

View file

@ -206,9 +206,9 @@ int ret;
if([self class] == [NSSavePanel class] &&
[[browser selectedCell] isLeaf] && ret == NSOKButton)
{
if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?",
@"Replace",@"Cancel",nil,[form stringValue],
[self directory]) == NSAlertAlternateReturn)
// if(NSRunAlertPanel(@"Save",@"The file %@ in %@ exists. Replace it?",
// @"Replace",@"Cancel",nil,[form stringValue],
// [self directory]) == NSAlertAlternateReturn)
return NSCancelButton;
}

View file

@ -423,8 +423,7 @@ NSPoint centerRectInRect(NSRect innerRect, NSRect outerRect)
if([self isOpaque])
{
[[self backgroundColor] set];
NSRectFill(r);
// [self _fillRect: [self bounds]];
[self _fillRect: [self bounds]];
}
/* draw the dimples */

View file

@ -9,7 +9,9 @@
Date: 1996
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: July 1998
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -30,17 +32,24 @@
#include <gnustep/gui/config.h>
#include <Foundation/NSString.h>
#include <AppKit/NSText.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSFontPanel.h>
#include <AppKit/NSFont.h>
#include <AppKit/NSColor.h>
#include <AppKit/NSSpellChecker.h>
#include <AppKit/NSPasteboard.h>
#include <AppKit/NSControl.h>
#include <Foundation/NSScanner.h>
#define ASSIGN(variable, value) [value retain]; \
[variable release]; \
variable = value;
//
// NSText implementation
//
@ -85,8 +94,10 @@
}
- (void)dealloc
{
[background_color release];
{
[background_color release];
[plainContent release];
[rtfContent release];
[super dealloc];
}
@ -94,30 +105,55 @@
//
// Getting and Setting Contents
//
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString
{
}
- (void)replaceCharactersInRange:(NSRange)range withRTF:(NSData *)rtfData
{
}
- (void)replaceCharactersInRange:(NSRange)range withRTFD:(NSData *)rtfdData
{
}
- (void)replaceRange:(NSRange)range withRTF:(NSData *)rtfData
{}
{
[self replaceRange:range withRTFD:rtfData];
}
- (void)replaceRange:(NSRange)range withRTFD:(NSData *)rtfdData
{}
{
}
- (NSData *)RTFDFromRange:(NSRange)range
{
{
return nil;
}
- (NSData *)RTFFromRange:(NSRange)range
{
return nil;
{
return [self RTFDFromRange:range];
}
- (void)setText:(NSString *)string
{
- (void)setString:(NSString *)string
{
ASSIGN(text_contents, string);
}
- (void)setText:(NSString *)string range:(NSRange)range
{
[self setSelectedRange:range];
- (NSString*)string
{
if([self isRichText])
return [rtfContent string];
else
return text_contents;
}
- (void)setText:(NSString *)string { [self setString:string]; }
- (void)setText:(NSString *)aString range:(NSRange)range
{
[self replaceCharactersInRange:(NSRange)range withString:aString];
}
- (NSString *)text { return text_contents; }
@ -175,7 +211,7 @@
- (BOOL)usesFontPanel { return uses_font_panel; }
- (void)changeFont:(id)sender
{
{
}
- (void)setBackgroundColor:(NSColor *)color
@ -183,8 +219,22 @@
ASSIGN(background_color, color);
}
- (void)setTextColor:(NSColor *)color ofRange:(NSRange)range
{
if([self isRichText])
{
if(color)
[rtfContent addAttribute:NSForegroundColorAttributeName
value:color
range:range];
else
{}
}
}
- (void)setColor:(NSColor *)color ofRange:(NSRange)range
{
{
[self setColor:color ofRange:range];
}
- (void)setFont:(NSFont *)obj
@ -193,7 +243,16 @@
}
- (void)setFont:(NSFont *)font ofRange:(NSRange)range
{
{
if([self isRichText])
{
if(font)
[rtfContent addAttribute:NSFontAttributeName
value:font
range:range];
else
{}
}
}
- (void)setTextColor:(NSColor *)color
@ -212,7 +271,7 @@
- (NSRange)selectedRange { return selected_range; }
- (void)setSelectedRange:(NSRange)range
{
{
selected_range = range;
}
@ -248,7 +307,7 @@
}
- (void)sizeToFit
{
{
}
//
@ -267,7 +326,23 @@
}
- (void)copy:(id)sender
{
{
NSMutableArray *types = [NSMutableArray arrayWithObjects:NSStringPboardType,
NSColorPboardType, nil];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
if([self isRichText])
[types addObject:NSRTFPboardType];
if([self importsGraphics])
[types addObject:NSRTFDPboardType];
[pboard declareTypes:types owner:self];
[pboard setString:[self string] forType:NSStringPboardType];
// if([self isRichText])
// [pboard setData:[[self class] dataForAttributedString:rtfContent]
// forType:NSRTFPboardType];
// if([self importsGraphics])
// [pboard setData:[[self class] dataForAttributedString:rtfContent]
// forType:NSRTFDPboardType];
}
- (void)copyFont:(id)sender
@ -278,16 +353,30 @@
{
}
- (void)cut:(id)sender
{
- (void)delete:(id)sender
{
NSRange selRange = [self selectedRange];
if(selRange.length)
[self replaceCharactersInRange:selRange withString:@""];
// move the cursor
[self setSelectedRange:NSMakeRange([self selectedRange].location,0)];
}
- (void)delete:(id)sender
{
- (void)cut:(id)sender
{
if([self selectedRange].length)
{
[self delete:self];
[self copy:self];
}
}
- (void)paste:(id)sender
{
{
// NSPasteboard *pboard = [NSPasteboard generalPasteboard];
//-(void) insertText:(NSString *)insertString
}
- (void)pasteFont:(id)sender
@ -324,33 +413,38 @@
- (BOOL)isRulerVisible { return NO; }
- (void)toggleRuler:(id)sender
{}
{
}
//
// Spelling
//
- (void)checkSpelling:(id)sender
{}
{
}
- (void)showGuessPanel:(id)sender
{}
{
[[NSSpellChecker sharedSpellChecker] orderFront:self];
}
//
// Scrolling
//
- (void)scrollRangeToVisible:(NSRange)range
{}
{
}
//
// Reading and Writing RTFD Files
//
- (BOOL)readRTFDFromFile:(NSString *)path
{
{
return NO;
}
- (BOOL)writeRTFDToFile:(NSString *)path atomically:(BOOL)flag
{
{
return NO;
}
@ -368,7 +462,7 @@
// Handling Events
//
- (void)mouseDown:(NSEvent *)theEvent
{
{
if (!is_selectable) // If not selectable then don't
return; // recognize the mouse down
[[self window] makeFirstResponder:self];
@ -435,8 +529,8 @@
- (void)textDidChange:(NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(textDidChange:)])
[delegate textDidChange:nil];
if ([delegate respondsToSelector:@selector(textDidChange:)])
[delegate textDidChange:nil];
}
- (void)textDidEndEditing:(NSNotification *)aNotification
@ -465,7 +559,7 @@
// Displaying
//
- (void)drawRect:(NSRect)rect
{
{
}
//
@ -475,13 +569,11 @@
{
[super encodeWithCoder:aCoder];
#if 0
[aCoder encodeObjectReference: delegate withName: @"Delegate"];
#else
[aCoder encodeConditionalObject:delegate];
#endif
[aCoder encodeObject: text_contents];
[aCoder encodeObject: plainContent];
[aCoder encodeObject: rtfContent];
[aCoder encodeValueOfObjCType: "I" at: &alignment];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_editable];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_rich_text];
@ -502,13 +594,11 @@
{
[super initWithCoder:aDecoder];
#if 0
[aDecoder decodeObjectAt: &delegate withName: NULL];
#else
delegate = [aDecoder decodeObject];
#endif
text_contents = [aDecoder decodeObject];
plainContent= [aDecoder decodeObject];
rtfContent= [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: "I" at: &alignment];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_editable];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_rich_text];
@ -532,12 +622,16 @@
// NSChangeSpelling protocol
//
- (void) changeSpelling:(id)sender
{}
{
[self replaceCharactersInRange:[self selectedRange]
withString:[[sender selectedCell] stringValue]];
}
//
// NSIgnoreMisspelledWords protocol
//
- (void)ignoreSpelling:(id)sender
{}
{
}
@end

View file

@ -5,6 +5,8 @@
Author: Daniel Bðhringer <boehring@biomed.ruhr-uni-bochum.de>
Date: August 1998
Source by Daniel Bðhringer integrated into GNUstep gui
by Felipe A. Rodriguez <far@ix.netcom.com>
This file is part of the GNUstep GUI Library.
@ -25,36 +27,19 @@
#include <AppKit/NSTextView.h>
#include <AppKit/NSPasteboard.h>
#include <AppKit/NSSpellChecker.h>
#include <AppKit/NSFontPanel.h>
#include <AppKit/NSControl.h>
#define ASSIGN(variable, value) [value retain]; \
[variable release]; \
variable = value;
@implementation NSTextView
-(void) insertText:(NSString *)insertString
{ // update previous line in case a word
// moved up on becoming shorter
unsigned lineIndex = MAX(0, [self lineLayoutIndexForCharacterIndex:
[self selectedRange].location - 1]);
//if(![delegate textDid...]) return; // also send notifications
if([self isRichText])
{
[self replaceRange:[self selectedRange]
withAttributedString:[[[NSAttributedString alloc]
initWithString:insertString attributes:[self typingAttributes]]
autorelease]];
[self rebuildRichLineLayoutInformationStartingAtLine:lineIndex];
}
else
{
[self replaceRange:[self selectedRange] withString:insertString];
[self rebuildPlainLineLayoutInformationStartingAtLine:lineIndex];
} // move the cursor
[self setSelectedRange:NSMakeRange([self selectedRange].location +
[insertString length],0)];
// [self displayRect:NSUnionRect([[lineLayoutInformation
// objectAtIndex:lineIndex] lineRect],
// [[lineLayoutInformation lastObject]lineRect])];
- (void)insertText:(NSString *)insertString
{
}
- (NSArray*)acceptableDragTypes
@ -66,6 +51,7 @@ NSMutableArray *ret = [NSMutableArray arrayWithObjects:NSStringPboardType,
[ret addObject:NSRTFPboardType];
if([self importsGraphics])
[ret addObject:NSRTFDPboardType];
return ret;
}
@ -91,7 +77,76 @@ NSMutableArray *ret = [NSMutableArray arrayWithObjects:NSStringPboardType,
}
break;
}
return proposedCharRange;
}
//
// Managing the Selection
//
- (void)setSelectedRange:(NSRange)range
{
selected_range = range;
if([self usesFontPanel]) // update fontPanel
{
BOOL isMultiple=NO;
NSFont *currentFont;
if([self isRichText])
{
// if(are multiple fonts in selection) isMultiple=YES;
// else currentFont=[rtfContent attribute:NSFontAttributeName
// atIndex:range.location longestEffectiveRange:NULL
// inRange:range]
}
else
currentFont = [[self defaultTypingAttributes]
objectForKey:NSFontAttributeName];
[[NSFontPanel sharedFontPanel] setPanelFont:currentFont
isMultiple:isMultiple];
}
if(range.length) // display
{
// disable caret timed entry
}
else
{
// enable caret timed entry
}
[self scrollRangeToVisible:range];
}
- (void)setTypingAttributes:(NSDictionary*) dict
{
ASSIGN(typingAttributes, dict);
}
- (NSDictionary*)typingAttributes
{
if(typingAttributes)
return typingAttributes;
else
return [self defaultTypingAttributes];
}
- (int) spellCheckerDocumentTag
{
if(!spellCheckerDocumentTag)
spellCheckerDocumentTag = [NSSpellChecker uniqueSpellDocumentTag];
return spellCheckerDocumentTag;
}
//
// NSIgnoreMisspelledWords protocol
//
- (void)ignoreSpelling:(id)sender
{
[[NSSpellChecker sharedSpellChecker]
ignoreWord:[[sender selectedCell] stringValue]
inSpellDocumentWithTag:[self spellCheckerDocumentTag]];
}
@end