mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:00:48 +00:00
Call super methods for pasteboard. Moved drag registration back to here.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6615 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a52411d79d
commit
ae4dbb7de7
1 changed files with 85 additions and 72 deletions
|
@ -29,7 +29,6 @@
|
||||||
#include <Foundation/NSProcessInfo.h>
|
#include <Foundation/NSProcessInfo.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
#include <AppKit/NSMatrix.h>
|
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
#include <AppKit/NSWindow.h>
|
#include <AppKit/NSWindow.h>
|
||||||
#include <AppKit/NSEvent.h>
|
#include <AppKit/NSEvent.h>
|
||||||
|
@ -39,10 +38,10 @@
|
||||||
#include <AppKit/NSRulerView.h>
|
#include <AppKit/NSRulerView.h>
|
||||||
#include <AppKit/NSPasteboard.h>
|
#include <AppKit/NSPasteboard.h>
|
||||||
#include <AppKit/NSSpellChecker.h>
|
#include <AppKit/NSSpellChecker.h>
|
||||||
#include <AppKit/NSFontPanel.h>
|
|
||||||
#include <AppKit/NSControl.h>
|
#include <AppKit/NSControl.h>
|
||||||
#include <AppKit/NSLayoutManager.h>
|
#include <AppKit/NSLayoutManager.h>
|
||||||
#include <AppKit/NSTextStorage.h>
|
#include <AppKit/NSTextStorage.h>
|
||||||
|
#include <AppKit/NSColorPanel.h>
|
||||||
|
|
||||||
@implementation NSTextView
|
@implementation NSTextView
|
||||||
|
|
||||||
|
@ -50,8 +49,6 @@
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
[super initialize];
|
|
||||||
|
|
||||||
if ([self class] == [NSTextView class])
|
if ([self class] == [NSTextView class])
|
||||||
{
|
{
|
||||||
[self setVersion: 1];
|
[self setVersion: 1];
|
||||||
|
@ -61,17 +58,12 @@
|
||||||
|
|
||||||
+ (void) registerForServices
|
+ (void) registerForServices
|
||||||
{
|
{
|
||||||
NSArray *r;
|
NSArray *types;
|
||||||
NSArray *s;
|
|
||||||
|
|
||||||
/*
|
types = [NSArray arrayWithObjects: NSStringPboardType, NSRTFPboardType, NSRTFDPboardType, nil];
|
||||||
* FIXME - should register for all types of data we support, not just string.
|
|
||||||
*/
|
|
||||||
r = [NSArray arrayWithObjects: NSStringPboardType, nil];
|
|
||||||
s = [NSArray arrayWithObjects: NSStringPboardType, nil];
|
|
||||||
|
|
||||||
[[NSApplication sharedApplication] registerServicesMenuSendTypes: s
|
[[NSApplication sharedApplication] registerServicesMenuSendTypes: types
|
||||||
returnTypes: r];
|
returnTypes: types];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initializing Methods */
|
/* Initializing Methods */
|
||||||
|
@ -83,6 +75,8 @@
|
||||||
|
|
||||||
[self setTextContainer: aTextContainer];
|
[self setTextContainer: aTextContainer];
|
||||||
[self setEditable: YES];
|
[self setEditable: YES];
|
||||||
|
[self setUsesFontPanel: YES];
|
||||||
|
[self setUsesRuler: YES];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +100,8 @@
|
||||||
- (void) setTextContainer: (NSTextContainer*)aTextContainer
|
- (void) setTextContainer: (NSTextContainer*)aTextContainer
|
||||||
{
|
{
|
||||||
ASSIGN(_textContainer, aTextContainer);
|
ASSIGN(_textContainer, aTextContainer);
|
||||||
|
// FIXME: Could also get a reference to the layout manager
|
||||||
|
ASSIGN(_textStorage, [[aTextContainer layoutManager] textStorage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTextContainer*) textContainer
|
- (NSTextContainer*) textContainer
|
||||||
|
@ -248,6 +244,7 @@
|
||||||
_tf.imports_graphics = flag;
|
_tf.imports_graphics = flag;
|
||||||
|
|
||||||
_tf.is_rich_text = flag;
|
_tf.is_rich_text = flag;
|
||||||
|
[self updateDragTypeRegistration];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isRichText
|
- (BOOL) isRichText
|
||||||
|
@ -261,6 +258,7 @@
|
||||||
_tf.is_rich_text = flag;
|
_tf.is_rich_text = flag;
|
||||||
|
|
||||||
_tf.imports_graphics = flag;
|
_tf.imports_graphics = flag;
|
||||||
|
[self updateDragTypeRegistration];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) importsGraphics
|
- (BOOL) importsGraphics
|
||||||
|
@ -395,8 +393,8 @@
|
||||||
- (NSString*) preferredPasteboardTypeFromArray: (NSArray*)availableTypes
|
- (NSString*) preferredPasteboardTypeFromArray: (NSArray*)availableTypes
|
||||||
restrictedToTypesFromArray: (NSArray*)allowedTypes
|
restrictedToTypesFromArray: (NSArray*)allowedTypes
|
||||||
{
|
{
|
||||||
// No idea.
|
return [super preferredPasteboardTypeFromArray: availableTypes
|
||||||
return nil;
|
restrictedToTypesFromArray: allowedTypes];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
|
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
|
||||||
|
@ -410,8 +408,7 @@ preferred type of data and then reads the data using the
|
||||||
readSelectionFromPasteboard: type: method. Returns YES if the
|
readSelectionFromPasteboard: type: method. Returns YES if the
|
||||||
data was successfully read.
|
data was successfully read.
|
||||||
*/
|
*/
|
||||||
|
return [super readSelectionFromPasteboard: pboard];
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
|
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
|
||||||
|
@ -427,19 +424,20 @@ default types. Use the rangeForUserTextChange method to obtain the range
|
||||||
of characters (if any) to be replaced by the new data.
|
of characters (if any) to be replaced by the new data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return NO;
|
return [super readSelectionFromPasteboard: pboard
|
||||||
|
type: type];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*) readablePasteboardTypes
|
- (NSArray*) readablePasteboardTypes
|
||||||
{
|
{
|
||||||
// get default types, what are they?
|
// get default types, what are they?
|
||||||
return nil;
|
return [super readablePasteboardTypes];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*) writablePasteboardTypes
|
- (NSArray*) writablePasteboardTypes
|
||||||
{
|
{
|
||||||
// the selected text can be written to the pasteboard with which types.
|
// the selected text can be written to the pasteboard with which types.
|
||||||
return nil;
|
return [super writablePasteboardTypes];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
|
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
|
||||||
|
@ -453,13 +451,13 @@ super's implementation of the method to handle any types of data your
|
||||||
overridden version does not.
|
overridden version does not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return NO;
|
return [super writeSelectionToPasteboard: pboard
|
||||||
|
type: type];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
|
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
|
||||||
types: (NSArray*)types
|
types: (NSArray*)types
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Writes the current selection to pboard under each type in the types
|
/* Writes the current selection to pboard under each type in the types
|
||||||
array. Returns YES if the data for any single type was written
|
array. Returns YES if the data for any single type was written
|
||||||
successfully.
|
successfully.
|
||||||
|
@ -467,19 +465,8 @@ successfully.
|
||||||
You should not need to override this method. You might need to invoke this
|
You should not need to override this method. You might need to invoke this
|
||||||
method if you are implementing a new type of pasteboard to handle services
|
method if you are implementing a new type of pasteboard to handle services
|
||||||
other than copy/paste or dragging. */
|
other than copy/paste or dragging. */
|
||||||
|
return [super writeSelectionToPasteboard: pboard
|
||||||
NSArray *mytypes;
|
types: types];
|
||||||
NSString *string;
|
|
||||||
|
|
||||||
if ([types containsObject: NSStringPboardType] == NO)
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
mytypes = [NSArray arrayWithObjects: NSStringPboardType, nil];
|
|
||||||
[pboard declareTypes: mytypes owner: nil];
|
|
||||||
string = [self string];
|
|
||||||
string = [string substringWithRange: _selected_range];
|
|
||||||
return [pboard setString: string forType: NSStringPboardType];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) alignJustified: (id)sender
|
- (void) alignJustified: (id)sender
|
||||||
|
@ -726,12 +713,14 @@ replacing the selection.
|
||||||
|
|
||||||
- (void) pasteAsPlainText: (id)sender
|
- (void) pasteAsPlainText: (id)sender
|
||||||
{
|
{
|
||||||
[self insertText: [sender string]];
|
[self readSelectionFromPasteboard: [NSPasteboard generalPasteboard]
|
||||||
|
type: NSStringPboardType];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) pasteAsRichText: (id)sender
|
- (void) pasteAsRichText: (id)sender
|
||||||
{
|
{
|
||||||
[self insertText: [sender string]];
|
[self readSelectionFromPasteboard: [NSPasteboard generalPasteboard]
|
||||||
|
type: NSRTFPboardType];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateFontPanel
|
- (void) updateFontPanel
|
||||||
|
@ -746,13 +735,19 @@ replacing the selection.
|
||||||
|
|
||||||
- (NSArray*) acceptableDragTypes
|
- (NSArray*) acceptableDragTypes
|
||||||
{
|
{
|
||||||
return nil;
|
return [self readablePasteboardTypes];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateDragTypeRegistration
|
- (void) updateDragTypeRegistration
|
||||||
{
|
{
|
||||||
|
// FIXME: Should change registration for all our text views
|
||||||
|
if (_tf.is_editable && _tf.is_rich_text)
|
||||||
|
[self registerForDraggedTypes: [self acceptableDragTypes]];
|
||||||
|
else
|
||||||
|
[self unregisterDraggedTypes];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSRange) selectionRangeForProposedRange: (NSRange)proposedSelRange
|
- (NSRange) selectionRangeForProposedRange: (NSRange)proposedSelRange
|
||||||
granularity: (NSSelectionGranularity)granularity
|
granularity: (NSSelectionGranularity)granularity
|
||||||
{
|
{
|
||||||
|
@ -775,6 +770,35 @@ replacing the selection.
|
||||||
return [super rangeForUserTextChange];
|
return [super rangeForUserTextChange];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (id) validRequestorForSendType: (NSString*)sendType
|
||||||
|
returnType: (NSString*)returnType
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Returns self if sendType specifies a type of data the text view can put on
|
||||||
|
the pasteboard and returnType contains a type of data the text view can
|
||||||
|
read from the pasteboard; otherwise returns nil.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [super validRequestorForSendType: sendType
|
||||||
|
returnType: returnType];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int) spellCheckerDocumentTag
|
||||||
|
{
|
||||||
|
return [super spellCheckerDocumentTag];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) insertText: (NSString*)aString
|
||||||
|
{
|
||||||
|
[super insertText: aString];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) sizeToFit
|
||||||
|
{
|
||||||
|
[super sizeToFit];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange
|
- (BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange
|
||||||
replacementString: (NSString*)replacementString
|
replacementString: (NSString*)replacementString
|
||||||
{
|
{
|
||||||
|
@ -814,14 +838,28 @@ the affected range or replacement string before beginning changes, pass
|
||||||
|
|
||||||
- (NSRange) smartDeleteRangeForProposedRange: (NSRange)proposedCharRange
|
- (NSRange) smartDeleteRangeForProposedRange: (NSRange)proposedCharRange
|
||||||
{
|
{
|
||||||
// FIXME.
|
// FIXME.
|
||||||
return proposedCharRange;
|
return proposedCharRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)smartInsertAfterStringForString: (NSString *)aString
|
||||||
|
replacingRange: (NSRange)charRange
|
||||||
|
{
|
||||||
|
// FIXME.
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)smartInsertBeforeStringForString: (NSString *)aString
|
||||||
|
replacingRange: (NSRange)charRange
|
||||||
|
{
|
||||||
|
// FIXME.
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) smartInsertForString: (NSString*)aString
|
- (void) smartInsertForString: (NSString*)aString
|
||||||
replacingRange: (NSRange)charRange
|
replacingRange: (NSRange)charRange
|
||||||
beforeString: (NSString*)beforeString
|
beforeString: (NSString**)beforeString
|
||||||
afterString: (NSString*)afterString
|
afterString: (NSString**)afterString
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Determines whether whitespace needs to be added around aString to
|
/* Determines whether whitespace needs to be added around aString to
|
||||||
|
@ -840,7 +878,13 @@ NSTextView uses this method as necessary. You can also use it in
|
||||||
implementing your own methods that insert text. To do so, invoke this
|
implementing your own methods that insert text. To do so, invoke this
|
||||||
method with the proper arguments, then insert beforeString, aString, and
|
method with the proper arguments, then insert beforeString, aString, and
|
||||||
afterString in order over charRange. */
|
afterString in order over charRange. */
|
||||||
|
if (beforeString)
|
||||||
|
*beforeString = [self smartInsertBeforeStringForString: aString
|
||||||
|
replacingRange: charRange];
|
||||||
|
|
||||||
|
if (afterString)
|
||||||
|
*afterString = [self smartInsertAfterStringForString: aString
|
||||||
|
replacingRange: charRange];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) resignFirstResponder
|
- (BOOL) resignFirstResponder
|
||||||
|
@ -876,27 +920,6 @@ afterString in order over charRange. */
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) validRequestorForSendType: (NSString*)sendType
|
|
||||||
returnType: (NSString*)returnType
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Returns self if sendType specifies a type of data the text view can put on
|
|
||||||
the pasteboard and returnType contains a type of data the text view can
|
|
||||||
read from the pasteboard; otherwise returns nil.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (int) spellCheckerDocumentTag
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
if (!_spellCheckerDocumentTag)
|
|
||||||
_spellCheckerDocumentTag = [[NSSpellingServer sharedServer] uniqueSpellDocumentTag];
|
|
||||||
*/
|
|
||||||
return _spellCheckerDocumentTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) rulerView: (NSRulerView*)aRulerView
|
- (void) rulerView: (NSRulerView*)aRulerView
|
||||||
didMoveMarker: (NSRulerMarker*)aMarker
|
didMoveMarker: (NSRulerMarker*)aMarker
|
||||||
{
|
{
|
||||||
|
@ -1020,16 +1043,6 @@ container, returning the modified location. */
|
||||||
SET_DELEGATE_NOTIFICATION(WillChangeNotifyingTextView);
|
SET_DELEGATE_NOTIFICATION(WillChangeNotifyingTextView);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) insertText: (NSString*)aString
|
|
||||||
{
|
|
||||||
[super insertText: aString];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) sizeToFit
|
|
||||||
{
|
|
||||||
[super sizeToFit];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) drawRect: (NSRect)aRect
|
- (void) drawRect: (NSRect)aRect
|
||||||
{
|
{
|
||||||
NSRange glyphRange;
|
NSRange glyphRange;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue