Various text/font fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6291 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-03-16 14:16:46 +00:00
parent b5be67ab7d
commit be2b1ba87b
6 changed files with 3091 additions and 3159 deletions

View file

@ -1,3 +1,9 @@
Thu Mar 16 13:15:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSText.m: Fixes by Fred Kiefer for rich text display.
* Source/NSTextView.m: ditto
* Source/NSFontManager.m: bugfixes - check for nil fonts.
Wed Mar 15 02:41:04 2000 Nicola Pero <n.pero@mi.flashnet.it> Wed Mar 15 02:41:04 2000 Nicola Pero <n.pero@mi.flashnet.it>
* Source/GSUtil.m: Removed file; it was duplicating * Source/GSUtil.m: Removed file; it was duplicating

View file

@ -84,7 +84,7 @@ typedef enum _NSSelectionGranularity {
NSSelectByParagraph = 2, NSSelectByParagraph = 2,
} NSSelectionGranularity; } NSSelectionGranularity;
#if GNUSTEP #ifndef NO_GNUSTEP
typedef enum _NSSelectionAffinity { typedef enum _NSSelectionAffinity {
NSSelectionAffinityUpstream = 0, NSSelectionAffinityUpstream = 0,
NSSelectionAffinityDownstream = 1, NSSelectionAffinityDownstream = 1,
@ -92,53 +92,51 @@ typedef enum _NSSelectionAffinity {
#endif #endif
@interface NSText : NSView <NSChangeSpelling,NSIgnoreMisspelledWords,NSCoding> @interface NSText : NSView <NSChangeSpelling,NSIgnoreMisspelledWords,NSCoding>
{ // Attributes {
id delegate; // Attributes
unsigned int alignment; //NSTextAlignment id _delegate;
BOOL is_editable; struct GSTextFlagsType {
BOOL is_rich_text; unsigned is_editable: 1;
BOOL is_selectable; unsigned is_rich_text: 1;
BOOL imports_graphics; unsigned is_selectable: 1;
BOOL uses_font_panel; unsigned imports_graphics: 1;
BOOL is_horizontally_resizable; unsigned uses_font_panel: 1;
BOOL is_vertically_resizable; unsigned is_horizontally_resizable: 1;
BOOL is_ruler_visible; unsigned is_vertically_resizable: 1;
BOOL is_field_editor; unsigned is_ruler_visible: 1;
BOOL draws_background; unsigned is_field_editor: 1;
NSColor *background_color; unsigned draws_background: 1;
NSColor *text_color; } _tf;
NSFont *default_font; NSTextAlignment _alignment;
NSRange selected_range; NSColor *_background_color;
NSColor *_text_color;
// added by Daniel Bðhringer NSFont *_default_font;
NSRange _selected_range;
NSSize minSize,maxSize; NSSize _minSize;
NSMutableDictionary *typingAttributes; NSSize _maxSize;
NSMutableDictionary *_typingAttributes;
// content // content
NSMutableString *plainContent; NSMutableAttributedString *_textStorage;
NSMutableAttributedString *rtfContent;
// internal stuff int _spellCheckerDocumentTag;
// column-stable cursor up/down
NSPoint _currentCursor;
// contains private _GNULineLayoutInfo objects // contains private _GNULineLayoutInfo objects
NSMutableArray *lineLayoutInformation; id _layoutManager;
int spellCheckerDocumentTag;
NSCharacterSet *selectionWordGranularitySet;
NSCharacterSet *selectionParagraphGranularitySet;
BOOL displayDisabled;
float currentCursorX; // column-stable cursor up/down
float currentCursorY; // column-stable cursor up/down
} }
// /*
// Getting and Setting Contents (low level: no selection handling, * Getting and Setting Contents
// relayout or display) */
// - (void) replaceCharactersInRange: (NSRange)aRange
- (void)replaceCharactersInRange:(NSRange)aRange withRTF:(NSData *)rtfData; withRTF: (NSData*)rtfData;
- (void)replaceCharactersInRange:(NSRange)aRange withRTFD:(NSData *)rtfdData; - (void) replaceCharactersInRange: (NSRange)aRange
- (void)replaceCharactersInRange:(NSRange)aRange withString:(NSString *)aString; withRTFD: (NSData*)rtfdData;
- (void) replaceCharactersInRange: (NSRange)aRange
withString: (NSString*)aString;
- (void) setString: (NSString*)string; - (void) setString: (NSString*)string;
- (NSString*) string; - (NSString*) string;
@ -151,18 +149,18 @@ typedef enum _NSSelectionAffinity {
range: (NSRange)aRange; range: (NSRange)aRange;
- (NSString*) text; - (NSString*) text;
// /*
// Graphic attributes * Graphic attributes
// */
- (NSColor*) backgroundColor; - (NSColor*) backgroundColor;
- (BOOL) drawsBackground; - (BOOL) drawsBackground;
- (void) setBackgroundColor: (NSColor*)color; - (void) setBackgroundColor: (NSColor*)color;
- (void) setDrawsBackground: (BOOL)flag; - (void) setDrawsBackground: (BOOL)flag;
// /*
// Managing Global Characteristics * Managing Global Characteristics
// */
- (BOOL) importsGraphics; - (BOOL) importsGraphics;
- (BOOL) isEditable; - (BOOL) isEditable;
- (BOOL) isFieldEditor; - (BOOL) isFieldEditor;
@ -174,27 +172,27 @@ typedef enum _NSSelectionAffinity {
- (void) setRichText: (BOOL)flag; - (void) setRichText: (BOOL)flag;
- (void) setSelectable: (BOOL)flag; - (void) setSelectable: (BOOL)flag;
// /*
// Using the font panel * Using the font panel
// */
- (void) setUsesFontPanel: (BOOL)flag; - (void) setUsesFontPanel: (BOOL)flag;
- (BOOL) usesFontPanel; - (BOOL) usesFontPanel;
// /*
// Managing the Ruler * Managing the Ruler
// */
- (BOOL) isRulerVisible; - (BOOL) isRulerVisible;
- (void) toggleRuler: (id)sender; - (void) toggleRuler: (id)sender;
// /*
// Managing the Selection * Managing the Selection
// */
- (NSRange) selectedRange; - (NSRange) selectedRange;
- (void) setSelectedRange: (NSRange)range; - (void) setSelectedRange: (NSRange)range;
// /*
// Responding to Editing Commands * Responding to Editing Commands
// */
- (void) copy: (id)sender; - (void) copy: (id)sender;
- (void) copyFont: (id)sender; - (void) copyFont: (id)sender;
- (void) copyRuler: (id)sender; - (void) copyRuler: (id)sender;
@ -205,50 +203,50 @@ typedef enum _NSSelectionAffinity {
- (void) pasteRuler: (id)sender; - (void) pasteRuler: (id)sender;
- (void) selectAll: (id)sender; - (void) selectAll: (id)sender;
// /*
// Managing Font * Managing Font
// */
- (void) changeFont: (id)sender; - (void) changeFont: (id)sender;
- (NSFont*) font; - (NSFont*) font;
- (void) setFont: (NSFont*)obj; - (void) setFont: (NSFont*)obj;
- (void) setFont: (NSFont*)font ofRange: (NSRange)range; - (void) setFont: (NSFont*)font ofRange: (NSRange)range;
// /*
// Managing Alingment * Managing Alignment
// */
- (NSTextAlignment) alignment; - (NSTextAlignment) alignment;
- (void) setAlignment: (NSTextAlignment)mode; - (void) setAlignment: (NSTextAlignment)mode;
- (void) alignCenter: (id)sender; - (void) alignCenter: (id)sender;
- (void) alignLeft: (id)sender; - (void) alignLeft: (id)sender;
- (void) alignRight: (id)sender; - (void) alignRight: (id)sender;
// /*
// Text colour * Text colour
// */
- (void) setTextColor: (NSColor*)color range: (NSRange)range; - (void) setTextColor: (NSColor*)color range: (NSRange)range;
- (void) setColor: (NSColor*)color ofRange: (NSRange)range; - (void) setColor: (NSColor*)color ofRange: (NSRange)range;
- (void) setTextColor: (NSColor*)color; - (void) setTextColor: (NSColor*)color;
- (NSColor*) textColor; - (NSColor*) textColor;
// /*
// Text attributes * Text attributes
// */
- (void) subscript: (id)sender; - (void) subscript: (id)sender;
- (void) superscript: (id)sender; - (void) superscript: (id)sender;
- (void) underline: (id)sender; - (void) underline: (id)sender;
- (void) unscript: (id)sender; - (void) unscript: (id)sender;
// /*
// Reading and Writing RTFD Files * Reading and Writing RTFD Files
// */
-(BOOL) readRTFDFromFile: (NSString*)path; -(BOOL) readRTFDFromFile: (NSString*)path;
-(BOOL) writeRTFDToFile: (NSString*)path atomically: (BOOL)flag; -(BOOL) writeRTFDToFile: (NSString*)path atomically: (BOOL)flag;
-(NSData*) RTFDFromRange: (NSRange)range; -(NSData*) RTFDFromRange: (NSRange)range;
-(NSData*) RTFFromRange: (NSRange)range; -(NSData*) RTFFromRange: (NSRange)range;
// /*
// Sizing the Frame Rectangle * Sizing the Frame Rectangle
// */
- (BOOL) isHorizontallyResizable; - (BOOL) isHorizontallyResizable;
- (BOOL) isVerticallyResizable; - (BOOL) isVerticallyResizable;
- (NSSize) maxSize; - (NSSize) maxSize;
@ -259,38 +257,37 @@ typedef enum _NSSelectionAffinity {
- (void) setVerticallyResizable: (BOOL)flag; - (void) setVerticallyResizable: (BOOL)flag;
- (void) sizeToFit; - (void) sizeToFit;
// /*
// Spelling * Spelling
// */
- (void) checkSpelling: (id)sender; - (void) checkSpelling: (id)sender;
- (void) showGuessPanel: (id)sender; - (void) showGuessPanel: (id)sender;
// /*
// Scrolling * Scrolling
// */
- (void) scrollRangeToVisible: (NSRange)range; - (void) scrollRangeToVisible: (NSRange)range;
// /*
// Managing the Delegate * Managing the Delegate
// */
- delegate; - (id) delegate;
-(void) setDelegate:anObject; - (void) setDelegate: (id)anObject;
/*
* NSCoding protocol
*/
- (void) encodeWithCoder: (NSCoder*)aCoder;
- (id) initWithCoder: (NSCoder*)aDecoder;
// /*
// NSCoding protocol * NSChangeSpelling protocol
// */
- (void)encodeWithCoder:aCoder;
- initWithCoder:aDecoder;
//
// NSChangeSpelling protocol
//
- (void) changeSpelling: (id)sender; - (void) changeSpelling: (id)sender;
// /*
// NSIgnoreMisspelledWords protocol * NSIgnoreMisspelledWords protocol
// */
- (void) ignoreSpelling: (id)sender; - (void) ignoreSpelling: (id)sender;
@end @end
@ -304,22 +301,28 @@ typedef enum _NSSelectionAffinity {
- (void) replaceRange: (NSRange)range - (void) replaceRange: (NSRange)range
withAttributedString: (NSAttributedString*)attrString; withAttributedString: (NSAttributedString*)attrString;
- (unsigned) textLength; - (unsigned) textLength;
- (NSRange) lineRangeForRect: (NSRect) rect;
- (NSRect) rectForCharacterIndex: (unsigned) index;
// //
// these NSTextView methods are here only informally (GNU extensions) // these NSTextView methods are here only informally (GNU extensions)
// //
- (int) spellCheckerDocumentTag; - (int) spellCheckerDocumentTag;
-(void) insertText:insertString; // argument may be of class NSString or NSAttributedString (if isRichText) // changed to only except class NSString
- (void) insertText: (NSString*)insertString;
- (NSMutableDictionary*) typingAttributes; - (NSMutableDictionary*) typingAttributes;
- (void) setTypingAttributes: (NSDictionary*)attrs; - (void) setTypingAttributes: (NSDictionary*)attrs;
-(BOOL) shouldDrawInsertionPoint; - (void) updateFontPanel;
-(void) drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag;
-(NSRange) selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity; // override if you want special cursor behaviour - (BOOL) shouldDrawInsertionPoint;
- (void) drawInsertionPointInRect: (NSRect)rect
color: (NSColor*)color
turnedOn: (BOOL)flag;
// override if you want special cursor behaviour
- (NSRange) selectionRangeForProposedRange: (NSRange)proposedCharRange
granularity: (NSSelectionGranularity)granularity;
- (NSArray*) acceptableDragTypes; - (NSArray*) acceptableDragTypes;
- (void) updateDragTypeRegistration; - (void) updateDragTypeRegistration;

View file

@ -365,8 +365,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font // We update our own selected font
if (_selectedFont != nil) if (_selectedFont != nil)
[self setSelectedFont: [self convertFont: _selectedFont] {
isMultiple: _multiple]; NSFont *newFont = [self convertFont: _selectedFont];
if (newFont != nil)
{
[self setSelectedFont: newFont isMultiple: _multiple];
}
}
} }
- (void) removeFontTrait: (id)sender - (void) removeFontTrait: (id)sender
@ -377,8 +383,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font // We update our own selected font
if (_selectedFont != nil) if (_selectedFont != nil)
[self setSelectedFont: [self convertFont: _selectedFont] {
isMultiple: _multiple]; NSFont *newFont = [self convertFont: _selectedFont];
if (newFont != nil)
{
[self setSelectedFont: newFont isMultiple: _multiple];
}
}
} }
- (void) modifyFont: (id)sender - (void) modifyFont: (id)sender
@ -388,8 +400,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font // We update our own selected font
if (_selectedFont != nil) if (_selectedFont != nil)
[self setSelectedFont: [self convertFont: _selectedFont] {
isMultiple: _multiple]; NSFont *newFont = [self convertFont: _selectedFont];
if (newFont != nil)
{
[self setSelectedFont: newFont isMultiple: _multiple];
}
}
} }
- (void) modifyFontViaPanel: (id)sender - (void) modifyFontViaPanel: (id)sender
@ -399,8 +417,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font // We update our own selected font
if (_selectedFont != nil) if (_selectedFont != nil)
[self setSelectedFont: [self convertFont: _selectedFont] {
isMultiple: _multiple]; NSFont *newFont = [self convertFont: _selectedFont];
if (newFont != nil)
{
[self setSelectedFont: newFont isMultiple: _multiple];
}
}
} }
/* /*

View file

@ -222,6 +222,8 @@ float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
//TODO: We go over every item in the panel and check if a //TODO: We go over every item in the panel and check if a
// value is selected. If so we send it on to the manager // value is selected. If so we send it on to the manager
// newFont = [fm convertFont: fontObject toHaveTrait: NSItalicFontMask]; // newFont = [fm convertFont: fontObject toHaveTrait: NSItalicFontMask];
NSLog(@"Multiple font conversion not implemented in NSFontPanel");
newFont = nil;
} }
else else
{ {

File diff suppressed because it is too large Load diff

View file

@ -934,8 +934,8 @@ container, returning the modified location. */
[super setDelegate: anObject]; [super setDelegate: anObject];
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([delegate respondsToSelector: @selector(textView##notif_name: )]) \ if ([_delegate respondsToSelector: @selector(textView##notif_name: )]) \
[nc addObserver: delegate \ [nc addObserver: _delegate \
selector: @selector(textView##notif_name: ) \ selector: @selector(textView##notif_name: ) \
name: NSTextView##notif_name##Notification \ name: NSTextView##notif_name##Notification \
object: self] object: self]