mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 03:50:39 +00:00
Removed ivar _textContainer. Added some delegate messages.
Two new NSTextView like methods for text container handling. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7671 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c037346069
commit
c4695f238c
1 changed files with 118 additions and 40 deletions
|
@ -1,12 +1,35 @@
|
|||
/*
|
||||
* GNUTextView.h
|
||||
*/
|
||||
/*
|
||||
NSTextView.h
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Author: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: September 2000
|
||||
Reformatted and cleaned up.
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; see the file COPYING.LIB.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSTextView
|
||||
#define _GNUstep_H_NSTextView
|
||||
|
||||
#import <AppKit/NSText.h>
|
||||
#import <AppKit/NSTextAttachment.h>
|
||||
#include <AppKit/NSText.h>
|
||||
#include <AppKit/NSTextAttachment.h>
|
||||
#include <AppKit/NSRulerView.h>
|
||||
#include <AppKit/NSRulerMarker.h>
|
||||
|
||||
|
@ -16,7 +39,6 @@
|
|||
|
||||
@interface NSTextView : NSText //<NSTextInput>
|
||||
{
|
||||
NSTextContainer *_textContainer;
|
||||
NSSize _textContainerInset;
|
||||
NSPoint _textContainerOrigin;
|
||||
NSDictionary *_selectedTextAttributes;
|
||||
|
@ -28,57 +50,78 @@
|
|||
/**************************** Initializing ****************************/
|
||||
|
||||
+(void) registerForServices;
|
||||
// This is sent each time a view is initialized. If you subclass you should ensure that you only register once.
|
||||
// This is sent each time a view is initialized. If you subclass you
|
||||
//should ensure that you only register once.
|
||||
|
||||
- initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)container;
|
||||
// Designated Initializer. container may be nil.
|
||||
- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)container;
|
||||
// Designated Initializer. container may be nil.
|
||||
|
||||
- initWithFrame:(NSRect)frameRect;
|
||||
// This variant will create the text network (textStorage, layoutManager, and a container).
|
||||
- (id)initWithFrame:(NSRect)frameRect;
|
||||
// This variant will create the text network (textStorage, layoutManager,
|
||||
// and a container).
|
||||
|
||||
/***************** Get/Set the container and other stuff *****************/
|
||||
|
||||
-(NSTextContainer*) textContainer;
|
||||
-(void)setTextContainer:(NSTextContainer*) container;
|
||||
// The set method should not be called directly, but you might want to override it. Gets or sets the text container for this view. Setting the text container marks the view as needing display. The text container calls the set method from its setTextView: method.
|
||||
// The set method should not be called directly, but you might want to override
|
||||
// it. Gets or sets the text container for this view. Setting the text container
|
||||
// marks the view as needing display. The text container calls the set method
|
||||
// from its setTextView: method.
|
||||
|
||||
- (void)replaceTextContainer:(NSTextContainer *)newContainer;
|
||||
// This method should be used instead of the primitive -setTextContainer: if you need to replace a view's text container with a new one leaving the rest of the web intact. This method deals with all the work of making sure the view doesn't get deallocated and removing the old container from the layoutManager and replacing it with the new one.
|
||||
// This method should be used instead of the primitive -setTextContainer: if you
|
||||
// need to replace a view's text container with a new one leaving the rest of the
|
||||
// web intact. This method deals with all the work of making sure the view doesn't
|
||||
// get deallocated and removing the old container from the layoutManager and
|
||||
// replacing it with the new one.
|
||||
|
||||
- (void)setTextContainerInset:(NSSize)inset;
|
||||
- (NSSize)textContainerInset;
|
||||
// The textContianerInset determines the padding that the view provides around the container. The container's origin will be inset by this amount from the bounds point {0,0} and padding will be left to the right and below the container of the same amount. This inset affects the view sizing in response to new layout and is used by the rectangular text containers when they track the view's frame dimensions.
|
||||
// The textContianerInset determines the padding that the view provides around the
|
||||
// container. The container's origin will be inset by this amount from the bounds
|
||||
// point {0,0} and padding will be left to the right and below the container of
|
||||
// the same amount. This inset affects the view sizing in response to new layout
|
||||
// and is used by the rectangular text containers when they track the view's frame
|
||||
// dimensions.
|
||||
|
||||
- (NSPoint)textContainerOrigin;
|
||||
- (void)invalidateTextContainerOrigin;
|
||||
// The container's origin in the view is determined from the current usage of the container, the container inset, and the view size. textContainerOrigin returns this point. invalidateTextContainerOrigin is sent automatically whenever something changes that causes the origin to possibly move. You usually do not need to call invalidate yourself.
|
||||
// The container's origin in the view is determined from the current usage of the
|
||||
// container, the container inset, and the view size. textContainerOrigin returns
|
||||
// this point. invalidateTextContainerOrigin is sent automatically whenever
|
||||
// something changes that causes the origin to possibly move. You usually do not
|
||||
// need to call invalidate yourself.
|
||||
|
||||
- (NSLayoutManager *)layoutManager;
|
||||
- (NSTextStorage *)textStorage;
|
||||
// Convenience methods
|
||||
// Convenience methods
|
||||
|
||||
/************************* Key binding entry-point *************************/
|
||||
|
||||
- (void)insertText:(NSString *)insertString;
|
||||
// This method is the funnel point for text insertion after keys pass through the key binder.
|
||||
// This method is the funnel point for text insertion after keys pass through the key binder.
|
||||
|
||||
/*************************** Sizing methods ***************************/
|
||||
|
||||
- (void)setConstrainedFrameSize:(NSSize)desiredSize;
|
||||
// Sets the frame size of the view to desiredSize constrained within min and max size.
|
||||
// Sets the frame size of the view to desiredSize constrained within min and max size.
|
||||
|
||||
/***************** New miscellaneous API above and beyond NSText *****************/
|
||||
|
||||
- (void)changeColor:(id)sender;
|
||||
// Called from NSColorPanel to set the text colour of the selection
|
||||
// Called from NSColorPanel to set the text colour of the selection
|
||||
|
||||
- (void)alignJustified:(id)sender;
|
||||
- (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;
|
||||
// These complete the set of range: type set methods. to be equivalent to the set of non-range taking varieties.
|
||||
// These complete the set of range: type set methods. to be equivalent to the set
|
||||
// of non-range taking varieties.
|
||||
|
||||
- (void)pasteAsPlainText:(id)sender;
|
||||
- (void)pasteAsRichText:(id)sender;
|
||||
// These methods are like paste: (from NSResponder) but they restrict the acceptable type of the pasted data. They are suitable as menu actions for appropriate "Paste As" submenu commands.
|
||||
// These methods are like paste: (from NSResponder) but they restrict the acceptable
|
||||
// type of the pasted data. They are suitable as menu actions for appropriate
|
||||
// "Paste As" submenu commands.
|
||||
|
||||
/*************************** New Font menu commands ***************************/
|
||||
|
||||
|
@ -99,9 +142,11 @@
|
|||
- (void)rulerView:(NSRulerView *)ruler didAddMarker:(NSRulerMarker *)marker;
|
||||
- (BOOL)rulerView:(NSRulerView *)ruler shouldMoveMarker:(NSRulerMarker *)marker;
|
||||
- (BOOL)rulerView:(NSRulerView *)ruler shouldAddMarker:(NSRulerMarker *)marker;
|
||||
- (float)rulerView:(NSRulerView *)ruler willMoveMarker:(NSRulerMarker *)marker toLocation:(float)location;
|
||||
- (float)rulerView:(NSRulerView *)ruler willMoveMarker:(NSRulerMarker *)marker
|
||||
toLocation:(float)location;
|
||||
- (BOOL)rulerView:(NSRulerView *)ruler shouldRemoveMarker:(NSRulerMarker *)marker;
|
||||
- (float)rulerView:(NSRulerView *)ruler willAddMarker:(NSRulerMarker *)marker atLocation:(float)location;
|
||||
- (float)rulerView:(NSRulerView *)ruler willAddMarker:(NSRulerMarker *)marker
|
||||
atLocation:(float)location;
|
||||
- (void)rulerView:(NSRulerView *)ruler handleMouseDown:(NSEvent *)event;
|
||||
|
||||
/*************************** Fine display control ***************************/
|
||||
|
@ -130,18 +175,20 @@
|
|||
- (NSArray *)acceptableDragTypes;
|
||||
- (void)updateDragTypeRegistration;
|
||||
|
||||
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange granularity:(NSSelectionGranularity)granularity;
|
||||
|
||||
|
||||
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange
|
||||
granularity:(NSSelectionGranularity)granularity;
|
||||
@end
|
||||
|
||||
@interface NSTextView (NSSharing)
|
||||
|
||||
// The methods in this category deal with settings that need to be shared by all the GNUTextViews of a single NSLayoutManager. Many of these methods are overrides of NSText or NSResponder methods.
|
||||
// The methods in this category deal with settings that need to be shared by all
|
||||
// the GNUTextViews of a single NSLayoutManager. Many of these methods are overrides
|
||||
// of NSText or NSResponder methods.
|
||||
|
||||
/*************************** Selected/Marked range ***************************/
|
||||
|
||||
- (void)setSelectedRange:(NSRange)charRange affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag;
|
||||
- (void)setSelectedRange:(NSRange)charRange affinity:(NSSelectionAffinity)affinity
|
||||
stillSelecting:(BOOL)stillSelectingFlag;
|
||||
- (NSSelectionAffinity)selectionAffinity;
|
||||
- (NSSelectionGranularity)selectionGranularity;
|
||||
- (void)setSelectionGranularity:(NSSelectionGranularity)granularity;
|
||||
|
@ -170,7 +217,8 @@
|
|||
- (NSDictionary *)typingAttributes;
|
||||
- (void)setTypingAttributes:(NSDictionary *)attrs;
|
||||
|
||||
- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;
|
||||
- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange
|
||||
replacementString:(NSString *)replacementString;
|
||||
- (void)didChangeText;
|
||||
|
||||
- (NSRange)rangeForUserTextChange;
|
||||
|
@ -227,30 +275,60 @@
|
|||
|
||||
@interface NSObject (NSTextViewDelegate)
|
||||
|
||||
- (void)textView:(NSTextView *)textView clickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame; // Delegate only.
|
||||
- (void)textView:(NSTextView *)textView
|
||||
clickedOnCell:(id <NSTextAttachmentCell>)cell
|
||||
inRect:(NSRect)cellFrame;
|
||||
- (void)textView:(NSTextView *)textView
|
||||
clickedOnCell:(id <NSTextAttachmentCell>)cell
|
||||
inRect:(NSRect)cellFrame
|
||||
atIndex:(unsigned)charIndex;
|
||||
|
||||
- (void)textView:(NSTextView *)textView doubleClickedOnCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame;
|
||||
// Delegate only.
|
||||
- (BOOL)textView:(NSTextView *)textView clickedOnLink:(id)link;
|
||||
- (BOOL)textView:(NSTextView *)textView
|
||||
clickedOnLink:(id)link
|
||||
atIndex:(unsigned)charIndex;
|
||||
|
||||
- (void)textView:(NSTextView *)view draggedCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)rect event:(NSEvent *)event;
|
||||
// Delegate only
|
||||
- (void)textView:(NSTextView *)textView
|
||||
doubleClickedOnCell:(id <NSTextAttachmentCell>)cell
|
||||
inRect:(NSRect)cellFrame;
|
||||
- (void)textView:(NSTextView *)textView
|
||||
doubleClickedOnCell:(id <NSTextAttachmentCell>)cell
|
||||
inRect:(NSRect)cellFrame
|
||||
atIndex:(unsigned)charIndex;
|
||||
|
||||
- (NSRange)textView:(NSTextView *)textView willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange toCharacterRange:(NSRange)newSelectedCharRange;
|
||||
// Delegate only.
|
||||
- (void)textView:(NSTextView *)view
|
||||
draggedCell:(id <NSTextAttachmentCell>)cell
|
||||
inRect:(NSRect)rect event:(NSEvent *)event;
|
||||
- (void)textView:(NSTextView *)view
|
||||
draggedCell:(id <NSTextAttachmentCell>)cell
|
||||
inRect:(NSRect)rect
|
||||
event:(NSEvent *)event
|
||||
atIndex:(unsigned)charIndex;
|
||||
|
||||
- (NSRange)textView:(NSTextView *)textView
|
||||
willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
|
||||
toCharacterRange:(NSRange)newSelectedCharRange;
|
||||
|
||||
- (void)textViewDidChangeSelection:(NSNotification *)notification;
|
||||
|
||||
- (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;
|
||||
// Delegate only. If characters are changing, replacementString is what will replace the affectedCharRange. If attributes only are changing, replacementString will be nil.
|
||||
- (BOOL)textView:(NSTextView *)textView
|
||||
shouldChangeTextInRange:(NSRange)affectedCharRange
|
||||
replacementString:(NSString *)replacementString;
|
||||
// If characters are changing, replacementString is what will replace the
|
||||
// affectedCharRange. If attributes only are changing, replacementString will be nil.
|
||||
|
||||
- (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector;
|
||||
|
||||
- (NSUndoManager *)undoManagerForTextView:(NSTextView *)view;
|
||||
@end
|
||||
|
||||
extern NSString *NSTextViewWillChangeNotifyingTextViewNotification;
|
||||
// NSOldNotifyingTextView -> the old view, NSNewNotifyingTextView -> the new view. The text view delegate is not automatically registered to receive this notification because the text machinery will automatically switch over the delegate to observe the new first text view as the first text view changes.
|
||||
// NSOldNotifyingTextView -> the old view, NSNewNotifyingTextView -> the new view.
|
||||
// The text view delegate is not automatically registered to receive this notification
|
||||
// because the text machinery will automatically switch over the delegate to observe
|
||||
// the new first text view as the first text view changes.
|
||||
|
||||
extern NSString *NSTextViewDidChangeSelectionNotification;
|
||||
// NSOldSelectedCharacterRange -> NSValue with old range.
|
||||
// NSOldSelectedCharacterRange -> NSValue with old range.
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue