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 Frith-MacDonald 2000-03-16 14:16:46 +00:00
parent 4424311814
commit 91e30dedde
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>
* Source/GSUtil.m: Removed file; it was duplicating

View file

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

View file

@ -365,8 +365,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font
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
@ -377,8 +383,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font
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
@ -388,8 +400,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font
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
@ -399,8 +417,14 @@ static Class fontPanelClass = Nil;
// We update our own selected font
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
// value is selected. If so we send it on to the manager
// newFont = [fm convertFont: fontObject toHaveTrait: NSItalicFontMask];
NSLog(@"Multiple font conversion not implemented in NSFontPanel");
newFont = nil;
}
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];
#define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([delegate respondsToSelector: @selector(textView##notif_name: )]) \
[nc addObserver: delegate \
if ([_delegate respondsToSelector: @selector(textView##notif_name: )]) \
[nc addObserver: _delegate \
selector: @selector(textView##notif_name: ) \
name: NSTextView##notif_name##Notification \
object: self]