Text tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6190 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-03-06 11:50:30 +00:00
parent 6a18da4e1e
commit 6a2530c043
2 changed files with 98 additions and 116 deletions

View file

@ -5,6 +5,8 @@ Mon Mar 06 10:36:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
of more efficient function based lookup. of more efficient function based lookup.
* Source/NSApplication.m: ditto * Source/NSApplication.m: ditto
* Source/NSMenu.m: ditto * Source/NSMenu.m: ditto
* Source/NSText.m: Tidyups by Fred.
* Headers/AppKit/NSText.h: ditto.
* Headers/AppKit/NSWindow.h tidyup. * Headers/AppKit/NSWindow.h tidyup.
* Headers/AppKit/NSGraphics.h new functions. * Headers/AppKit/NSGraphics.h new functions.

View file

@ -132,70 +132,59 @@ typedef enum _NSSelectionAffinity {
float currentCursorY; // column-stable cursor up/down float currentCursorY; // column-stable cursor up/down
} }
// GNU utility methods
// return value is guaranteed to be a NSAttributedString,
// even if data contains only NSString
+(NSAttributedString*) attributedStringForData:(NSData*) aData;
+(NSData*) dataForAttributedString:(NSAttributedString*) aString;
// GNU extension (override it if you want other characters treated
// as newline characters)
+(NSString*) newlineString;
// //
// Getting and Setting Contents (low level: no selection handling, // Getting and Setting Contents (low level: no selection handling,
// relayout or display) // relayout or display)
// //
-(void) replaceRange:(NSRange)range - (void)replaceCharactersInRange:(NSRange)aRange withRTF:(NSData *)rtfData;
withAttributedString:(NSAttributedString*)attrString; // GNU extension - (void)replaceCharactersInRange:(NSRange)aRange withRTFD:(NSData *)rtfdData;
- (void)replaceCharactersInRange:(NSRange)aRange withString:(NSString *)aString;
-(void) setString:(NSString *)string;
-(NSString*) string;
// old fashioned
-(void) replaceRange:(NSRange)range withString:(NSString*) aString; -(void) replaceRange:(NSRange)range withString:(NSString*) aString;
-(void) replaceRange:(NSRange)range withRTF:(NSData *)rtfData; -(void) replaceRange:(NSRange)range withRTF:(NSData *)rtfData;
-(void) replaceRange:(NSRange)range withRTFD:(NSData *)rtfdData; -(void) replaceRange:(NSRange)range withRTFD:(NSData *)rtfdData;
-(NSData*) RTFDFromRange:(NSRange)range; -(void) setText:(NSString *)string;
-(NSData*) RTFFromRange:(NSRange)range;
-(void) setString:(NSString *)string;
-(void) setText:(NSString *)string; // old fashioned
-(void) setText:(NSString*) aString -(void) setText:(NSString*) aString
range:(NSRange) aRange; // old fashioned range:(NSRange) aRange;
-(NSString*) string; -(NSString*) text;
-(NSString*) text; // old fashioned
-(unsigned) textLength; // GNU extension //
// Graphic attributes
//
- (NSColor *) backgroundColor;
- (BOOL) drawsBackground;
- (void) setBackgroundColor:(NSColor *)color;
- (void) setDrawsBackground:(BOOL)flag;
// //
// Managing Global Characteristics // Managing Global Characteristics
// //
- (NSTextAlignment)alignment;
- (BOOL)drawsBackground;
- (BOOL)importsGraphics; - (BOOL)importsGraphics;
- (BOOL)isEditable; - (BOOL)isEditable;
- (BOOL)isFieldEditor;
- (BOOL)isRichText; - (BOOL)isRichText;
- (BOOL)isSelectable; - (BOOL)isSelectable;
- (void)setAlignment:(NSTextAlignment)mode;
- (void)setDrawsBackground:(BOOL)flag;
- (void)setEditable:(BOOL)flag; - (void)setEditable:(BOOL)flag;
- (void)setFieldEditor:(BOOL)flag;
- (void)setImportsGraphics:(BOOL)flag; - (void)setImportsGraphics:(BOOL)flag;
- (void)setRichText:(BOOL)flag; - (void)setRichText:(BOOL)flag;
- (void)setSelectable:(BOOL)flag; - (void)setSelectable:(BOOL)flag;
// //
// Managing Font and Color // Using the font panel
//
- (void) setUsesFontPanel: (BOOL) flag;
- (BOOL) usesFontPanel;
// //
- (NSColor *)backgroundColor; // Managing the Ruler
- (void)changeFont:(id)sender; //
- (NSFont *)font; - (BOOL)isRulerVisible;
- (void)setBackgroundColor:(NSColor *)color; - (void)toggleRuler:(id)sender;
-(void) setTextColor:(NSColor *)color range:(NSRange)range;
- (void)setColor:(NSColor *)color ofRange:(NSRange)range;
- (void)setFont:(NSFont *)obj;
- (void)setFont:(NSFont *)font ofRange:(NSRange)range;
- (void)setTextColor:(NSColor *)color;
- (void)setUsesFontPanel:(BOOL)flag;
- (NSColor *)textColor;
- (BOOL)usesFontPanel;
// //
// Managing the Selection // Managing the Selection
@ -203,6 +192,60 @@ withAttributedString:(NSAttributedString*)attrString; // GNU extension
- (NSRange)selectedRange; - (NSRange)selectedRange;
- (void)setSelectedRange:(NSRange)range; - (void)setSelectedRange:(NSRange)range;
//
// Responding to Editing Commands
//
- (void)copy:(id)sender;
- (void)copyFont:(id)sender;
- (void)copyRuler:(id)sender;
- (void)cut:(id)sender;
- (void)delete:(id)sender;
- (void)paste:(id)sender;
- (void)pasteFont:(id)sender;
- (void)pasteRuler:(id)sender;
- (void)selectAll:(id)sender;
//
// Managing Font
//
- (void)changeFont:(id)sender;
- (NSFont *)font;
- (void)setFont:(NSFont *)obj;
- (void)setFont:(NSFont *)font ofRange:(NSRange)range;
//
// Managing Alingment
//
- (NSTextAlignment) alignment;
- (void) setAlignment: (NSTextAlignment) mode;
- (void)alignCenter:(id)sender;
- (void)alignLeft:(id)sender;
- (void)alignRight:(id)sender;
//
// Text colour
//
- (void) setTextColor:(NSColor *)color range:(NSRange)range;
- (void) setColor:(NSColor *)color ofRange:(NSRange)range;
- (void) setTextColor:(NSColor *)color;
- (NSColor *)textColor;
//
// Text attributes
//
- (void)subscript:(id)sender;
- (void)superscript:(id)sender;
- (void)underline:(id)sender;
- (void)unscript:(id)sender;
//
// Reading and Writing RTFD Files
//
-(BOOL) readRTFDFromFile:(NSString *)path;
-(BOOL) writeRTFDToFile:(NSString *)path atomically:(BOOL)flag;
-(NSData*) RTFDFromRange:(NSRange)range;
-(NSData*) RTFFromRange:(NSRange)range;
// //
// Sizing the Frame Rectangle // Sizing the Frame Rectangle
// //
@ -216,32 +259,6 @@ withAttributedString:(NSAttributedString*)attrString; // GNU extension
- (void)setVerticallyResizable:(BOOL)flag; - (void)setVerticallyResizable:(BOOL)flag;
- (void)sizeToFit; - (void)sizeToFit;
//
// Responding to Editing Commands
//
- (void)alignCenter:(id)sender;
- (void)alignLeft:(id)sender;
- (void)alignRight:(id)sender;
- (void)copy:(id)sender;
- (void)copyFont:(id)sender;
- (void)copyRuler:(id)sender;
- (void)cut:(id)sender;
- (void)delete:(id)sender;
- (void)paste:(id)sender;
- (void)pasteFont:(id)sender;
- (void)pasteRuler:(id)sender;
- (void)selectAll:(id)sender;
- (void)subscript:(id)sender;
- (void)superscript:(id)sender;
- (void)underline:(id)sender;
- (void)unscript:(id)sender;
//
// Managing the Ruler
//
- (BOOL)isRulerVisible;
- (void)toggleRuler:(id)sender;
// //
// Spelling // Spelling
// //
@ -253,18 +270,6 @@ withAttributedString:(NSAttributedString*)attrString; // GNU extension
// //
- (void)scrollRangeToVisible:(NSRange)range; - (void)scrollRangeToVisible:(NSRange)range;
//
// Reading and Writing RTFD Files
//
-(BOOL) readRTFDFromFile:(NSString *)path;
-(BOOL) writeRTFDToFile:(NSString *)path atomically:(BOOL)flag;
//
// Managing the Field Editor
//
- (BOOL)isFieldEditor;
- (void)setFieldEditor:(BOOL)flag;
// //
// Managing the Delegate // Managing the Delegate
// //
@ -287,6 +292,18 @@ withAttributedString:(NSAttributedString*)attrString; // GNU extension
// NSIgnoreMisspelledWords protocol // NSIgnoreMisspelledWords protocol
// //
- (void)ignoreSpelling:(id)sender; - (void)ignoreSpelling:(id)sender;
@end
@interface NSText(GNUstepExtension)
// GNU extension (override it if you want other characters treated
// as newline characters)
+(NSString*) newlineString;
// GNU extension
-(void) replaceRange:(NSRange)range
withAttributedString:(NSAttributedString*)attrString;
-(unsigned) textLength;
// //
// these NSTextView methods are here only informally (GNU extensions) // these NSTextView methods are here only informally (GNU extensions)
@ -297,50 +314,13 @@ withAttributedString:(NSAttributedString*)attrString; // GNU extension
-(NSMutableDictionary*) typingAttributes; -(NSMutableDictionary*) typingAttributes;
-(void) setTypingAttributes:(NSDictionary *)attrs; -(void) setTypingAttributes:(NSDictionary *)attrs;
-(BOOL) shouldDrawInsertionPoint; -(BOOL) shouldDrawInsertionPoint;
-(void) drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag; -(void) drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag;
-(NSArray*) acceptableDragTypes;
-(void) updateDragTypeRegistration;
-(NSRange) selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity; // override if you want special cursor behaviour -(NSRange) selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity; // override if you want special cursor behaviour
// -(NSArray*) acceptableDragTypes;
// these NSLayoutManager- like methods are here only informally (GNU extensions) -(void) updateDragTypeRegistration;
//
-(unsigned) characterIndexForPoint:(NSPoint)point;
-(NSRect) rectForCharacterIndex:(unsigned) index;
-(NSRect) boundingRectForLineRange:(NSRange)lineRange;
-(NSRange) characterRangeForBoundingRect:(NSRect)bounds;
-(NSRange) lineRangeForRect:(NSRect) aRect;
//
// these are implementation specific (GNU extensions)
//
-(int) rebuildLineLayoutInformationStartingAtLine:(int) aLine; // returns count of lines actually updated (e.g. drawing optimization)
-(int) rebuildLineLayoutInformationStartingAtLine:(int) aLine delta:(int) insertionDelta actualLine:(int) insertionLine; // override for special layout of text
-(int) lineLayoutIndexForCharacterIndex:(unsigned) anIndex; // return value is identical to the real line number (plus counted newline characters)
-(void) redisplayForLineRange:(NSRange) redrawLineRange;
-(void) drawRichLinesInLineRange:(NSRange) aRange; // low level, override but never invoke (use redisplayForLineRange:)
-(void) drawPlainLinesInLineRange:(NSRange) aRange; // low level, override but never invoke (use redisplayForLineRange:)
//
// various GNU extensions
//
-(void) rebuildFromCharacterIndex:(int) anIndex;
-(void) setSelectionWordGranularitySet:(NSCharacterSet*) aSet;
-(void) setSelectionParagraphGranularitySet:(NSCharacterSet*) aSet;
//
// private (never invoke, never subclass)
//
-(void) drawRectNoSelection:(NSRect)rect;
@end @end
/* Notifications */ /* Notifications */