diff options
-rw-r--r-- | cocoa/ScintillaCocoa.h | 3 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 12 | ||||
-rw-r--r-- | cocoa/ScintillaView.h | 56 | ||||
-rw-r--r-- | cocoa/ScintillaView.mm | 44 |
4 files changed, 59 insertions, 56 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 25b9807d7..23c84e616 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -88,6 +88,7 @@ namespace Scintilla { class ScintillaCocoa : public ScintillaBase { private: + ScintillaView* sciView; TimerTarget* timerTarget; NSEvent* lastMouseEvent; @@ -131,7 +132,7 @@ protected: virtual void CancelModes(); public: - ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin); + ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewContent, SCIMarginView* viewMargin); virtual ~ScintillaCocoa(); void SetDelegate(id<ScintillaNotificationProtocol> delegate_); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 90752d71c..076d6fcde 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -395,11 +395,15 @@ const CGFloat paddingHighlightY = 2; //----------------- ScintillaCocoa ----------------------------------------------------------------- -ScintillaCocoa::ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin) +ScintillaCocoa::ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewContent, SCIMarginView* viewMargin) { vs.marginInside = false; - wMain = view; // Don't retain since we're owned by view, which would cause a cycle + + // Don't retain since we're owned by view, which would cause a cycle + sciView = sciView_; + wMain = viewContent; wMargin = viewMargin; + timerTarget = [[TimerTarget alloc] init: this]; lastMouseEvent = NULL; delegate = NULL; @@ -896,7 +900,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_SETPHASESDRAW: { sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam); - [ContentView().owner updateIndicatorIME]; + [sciView updateIndicatorIME]; return r; } @@ -1999,7 +2003,7 @@ bool ScintillaCocoa::SetScrollingSize(void) { SetVerticalScrollPos(); enteredSetScrollingSize = false; } - [inner.owner setMarginWidth: vs.fixedColumnWidth]; + [sciView setMarginWidth: vs.fixedColumnWidth]; return changes; } diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h index 4194ec4e9..8c4cdfe2e 100644 --- a/cocoa/ScintillaView.h +++ b/cocoa/ScintillaView.h @@ -36,8 +36,6 @@ */ typedef void(*SciNotifyFunc) (intptr_t windowid, unsigned int iMessage, uintptr_t wParam, uintptr_t lParam); -@class ScintillaView; - extern NSString *const SCIUpdateUINotification; @protocol ScintillaNotificationProtocol @@ -47,18 +45,7 @@ extern NSString *const SCIUpdateUINotification; /** * SCIMarginView draws line numbers and other margins next to the text view. */ -@interface SCIMarginView : NSRulerView -{ -@private - int marginWidth; - ScintillaView *owner; - NSMutableArray *currentCursors; -} - -@property (assign) int marginWidth; -@property (assign) ScintillaView *owner; - -- (id)initWithScrollView:(NSScrollView *)aScrollView; +@interface SCIMarginView : NSRulerView; @end @@ -71,43 +58,18 @@ extern NSString *const SCIUpdateUINotification; NSUserInterfaceValidations, NSDraggingSource, NSDraggingDestination, - NSAccessibilityStaticText> -{ -@private - ScintillaView* mOwner; - NSCursor* mCurrentCursor; - NSTrackingArea *trackingArea; - - // Set when we are in composition mode and partial input is displayed. - NSRange mMarkedTextRange; -} - -@property (nonatomic, assign) ScintillaView* owner; - -- (void) setCursor: (int) cursor; + NSAccessibilityStaticText>; -- (BOOL) canUndo; -- (BOOL) canRedo; +- (void) setCursor: (int) cursor; // Needed by ScintillaCocoa @end -@interface ScintillaView : NSView <InfoBarCommunicator, ScintillaNotificationProtocol> -{ -@private - // This is the actual content to which the backend renders itself. - SCIContentView* mContent; - - NSScrollView *scrollView; - SCIMarginView *marginView; - - CGFloat zoomDelta; - - // Area to display additional controls (e.g. zoom info, caret position, status info). - NSView <InfoBarCommunicator>* mInfoBar; - BOOL mInfoBarAtTop; - - id<ScintillaNotificationProtocol> mDelegate; -} +/** + * ScintillaView is the class instantiated by client code. + * It contains an NSScrollView which contains a SCIMarginView and a SCIContentView. + * It is responsible for providing an API and communicating to a delegate. + */ +@interface ScintillaView : NSView <InfoBarCommunicator, ScintillaNotificationProtocol>; @property (nonatomic, assign) id<ScintillaNotificationProtocol> delegate; @property (nonatomic, readonly) NSScrollView *scrollView; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 292a2b982..7000d96e3 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -15,7 +15,8 @@ using namespace Scintilla; -// Add backend property as a private category +// Add backend property to ScintillaView as a private category. +// Specified here as backend accessed by SCIMarginView and SCIContentView. @interface ScintillaView () @property (nonatomic, readonly) Scintilla::ScintillaCocoa* backend; @end @@ -51,8 +52,17 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) } } +// Add marginWidth and owner properties as a private category. +@interface SCIMarginView () +@property (assign) int marginWidth; +@property (nonatomic, assign) ScintillaView* owner; +@end -@implementation SCIMarginView +@implementation SCIMarginView { + int marginWidth; + ScintillaView *owner; + NSMutableArray *currentCursors; +} @synthesize marginWidth, owner; @@ -160,7 +170,19 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) @end -@implementation SCIContentView +// Add owner property as a private category. +@interface SCIContentView () +@property (nonatomic, assign) ScintillaView* owner; +@end + +@implementation SCIContentView { + ScintillaView* mOwner; + NSCursor* mCurrentCursor; + NSTrackingArea *trackingArea; + + // Set when we are in composition mode and partial input is displayed. + NSRange mMarkedTextRange; +} @synthesize owner = mOwner; @@ -1190,6 +1212,20 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context // The back end is kind of a controller and model in one. // It uses the content view for display. Scintilla::ScintillaCocoa* mBackend; + + // This is the actual content to which the backend renders itself. + SCIContentView* mContent; + + NSScrollView *scrollView; + SCIMarginView *marginView; + + CGFloat zoomDelta; + + // Area to display additional controls (e.g. zoom info, caret position, status info). + NSView <InfoBarCommunicator>* mInfoBar; + BOOL mInfoBarAtTop; + + id<ScintillaNotificationProtocol> mDelegate; } @synthesize backend = mBackend; @@ -1442,7 +1478,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context [scrollView setHasVerticalRuler:YES]; [scrollView setRulersVisible:YES]; - mBackend = new ScintillaCocoa(mContent, marginView); + mBackend = new ScintillaCocoa(self, mContent, marginView); // Establish a connection from the back end to this container so we can handle situations // which require our attention. |