! Handle Open events from the Finder
CLASS: FactorWorkspaceApplicationDelegate < FactorApplicationDelegate
-[
- METHOD: void application: id app openFiles: id files [ files finder-run-files ]
- METHOD: int applicationShouldHandleReopen: id app hasVisibleWindows: int flag [ flag 0 = [ show-listener ] when 1 ]
+ METHOD: void application: id app openFiles: id files [ files finder-run-files ] ;
+
+ METHOD: int applicationShouldHandleReopen: id app hasVisibleWindows: int flag [ flag 0 = [ show-listener ] when 1 ] ;
- METHOD: id factorListener: id app [ show-listener f ]
+ METHOD: id factorListener: id app [ show-listener f ] ;
- METHOD: id factorBrowser: id app [ show-browser f ]
+ METHOD: id factorBrowser: id app [ show-browser f ] ;
- METHOD: id newFactorListener: id app [ listener-window f ]
+ METHOD: id newFactorListener: id app [ listener-window f ] ;
- METHOD: id newFactorBrowser: id app [ browser-window f ]
+ METHOD: id newFactorBrowser: id app [ browser-window f ] ;
- METHOD: id runFactorFile: id app [ menu-run-files f ]
+ METHOD: id runFactorFile: id app [ menu-run-files f ] ;
- METHOD: id saveFactorImage: id app [ save f ]
+ METHOD: id saveFactorImage: id app [ save f ] ;
- METHOD: id saveFactorImageAs: id app [ menu-save-image f ]
+ METHOD: id saveFactorImageAs: id app [ menu-save-image f ] ;
- METHOD: id refreshAll: id app [ [ refresh-all ] \ refresh-all call-listener f ]
-]
+ METHOD: id refreshAll: id app [ [ refresh-all ] \ refresh-all call-listener f ] ;
+;
: install-app-delegate ( -- )
NSApp FactorWorkspaceApplicationDelegate install-delegate ;
[ pboard set-pasteboard-string ] when* ;
CLASS: FactorServiceProvider < NSObject
-[
+
METHOD: void evalInListener: id pboard userData: id userData error: id error
- [ pboard error [ eval-listener f ] do-service ]
+ [ pboard error [ eval-listener f ] do-service ] ;
METHOD: void evalToString: id pboard userData: id userData error: id error
[
pboard error
[ [ (eval>string) ] with-interactive-vocabs ] do-service
- ]
-]
+ ] ;
+;
: register-services ( -- )
NSApp
selector>action at
[ swap world-focus parents-handle-gesture? t ] [ drop f f ] if* ;
-CLASS: FactorView < NSOpenGLView NSTextInput
-[
+CLASS: FactorView < NSOpenGLView
+ COCOA-PROTOCOL: NSTextInput
METHOD: void prepareOpenGL [
] [ drop ] if
] when
- ]
+ ] ;
! Rendering
- METHOD: void drawRect: NSRect rect [ self window [ draw-world ] when* ]
+ METHOD: void drawRect: NSRect rect [ self window [ draw-world ] when* ] ;
! Events
- METHOD: char acceptsFirstMouse: id event [ 0 ]
+ METHOD: char acceptsFirstMouse: id event [ 0 ] ;
- METHOD: void mouseEntered: id event [ self event send-mouse-moved ]
+ METHOD: void mouseEntered: id event [ self event send-mouse-moved ] ;
- METHOD: void mouseExited: id event [ forget-rollover ]
+ METHOD: void mouseExited: id event [ forget-rollover ] ;
- METHOD: void mouseMoved: id event [ self event send-mouse-moved ]
+ METHOD: void mouseMoved: id event [ self event send-mouse-moved ] ;
- METHOD: void mouseDragged: id event [ self event send-mouse-moved ]
+ METHOD: void mouseDragged: id event [ self event send-mouse-moved ] ;
- METHOD: void rightMouseDragged: id event [ self event send-mouse-moved ]
+ METHOD: void rightMouseDragged: id event [ self event send-mouse-moved ] ;
- METHOD: void otherMouseDragged: id event [ self event send-mouse-moved ]
+ METHOD: void otherMouseDragged: id event [ self event send-mouse-moved ] ;
- METHOD: void mouseDown: id event [ self event send-button-down$ ]
+ METHOD: void mouseDown: id event [ self event send-button-down$ ] ;
- METHOD: void mouseUp: id event [ self event send-button-up$ ]
+ METHOD: void mouseUp: id event [ self event send-button-up$ ] ;
- METHOD: void rightMouseDown: id event [ self event send-button-down$ ]
+ METHOD: void rightMouseDown: id event [ self event send-button-down$ ] ;
- METHOD: void rightMouseUp: id event [ self event send-button-up$ ]
+ METHOD: void rightMouseUp: id event [ self event send-button-up$ ] ;
- METHOD: void otherMouseDown: id event [ self event send-button-down$ ]
+ METHOD: void otherMouseDown: id event [ self event send-button-down$ ] ;
- METHOD: void otherMouseUp: id event [ self event send-button-up$ ]
+ METHOD: void otherMouseUp: id event [ self event send-button-up$ ] ;
- METHOD: void scrollWheel: id event [ self event send-scroll$ ]
+ METHOD: void scrollWheel: id event [ self event send-scroll$ ] ;
- METHOD: void keyDown: id event [ self event send-key-down-event ]
+ METHOD: void keyDown: id event [ self event send-key-down-event ] ;
- METHOD: void keyUp: id event [ self event send-key-up-event ]
+ METHOD: void keyUp: id event [ self event send-key-up-event ] ;
METHOD: char validateUserInterfaceItem: id event
[
event -> action utf8 alien>string validate-action
[ >c-bool ] [ drop self event SUPER-> validateUserInterfaceItem: ] if
] [ 0 ] if*
- ]
+ ] ;
- METHOD: id undo: id event [ self event undo-action send-action$ f ]
+ METHOD: id undo: id event [ self event undo-action send-action$ f ] ;
- METHOD: id redo: id event [ self event redo-action send-action$ f ]
+ METHOD: id redo: id event [ self event redo-action send-action$ f ] ;
- METHOD: id cut: id event [ self event cut-action send-action$ f ]
+ METHOD: id cut: id event [ self event cut-action send-action$ f ] ;
- METHOD: id copy: id event [ self event copy-action send-action$ f ]
+ METHOD: id copy: id event [ self event copy-action send-action$ f ] ;
- METHOD: id paste: id event [ self event paste-action send-action$ f ]
+ METHOD: id paste: id event [ self event paste-action send-action$ f ] ;
- METHOD: id delete: id event [ self event delete-action send-action$ f ]
+ METHOD: id delete: id event [ self event delete-action send-action$ f ] ;
- METHOD: id selectAll: id event [ self event select-all-action send-action$ f ]
+ METHOD: id selectAll: id event [ self event select-all-action send-action$ f ] ;
- METHOD: id newDocument: id event [ self event new-action send-action$ f ]
+ METHOD: id newDocument: id event [ self event new-action send-action$ f ] ;
- METHOD: id openDocument: id event [ self event open-action send-action$ f ]
+ METHOD: id openDocument: id event [ self event open-action send-action$ f ] ;
- METHOD: id saveDocument: id event [ self event save-action send-action$ f ]
+ METHOD: id saveDocument: id event [ self event save-action send-action$ f ] ;
- METHOD: id saveDocumentAs: id event [ self event save-as-action send-action$ f ]
+ METHOD: id saveDocumentAs: id event [ self event save-as-action send-action$ f ] ;
- METHOD: id revertDocumentToSaved: id event [ self event revert-action send-action$ f ]
+ METHOD: id revertDocumentToSaved: id event [ self event revert-action send-action$ f ] ;
! Multi-touch gestures
METHOD: void magnifyWithEvent: id event
{ -1 [ zoom-out-action send-action$ ] }
{ 0 [ 2drop ] }
} case
- ]
+ ] ;
METHOD: void swipeWithEvent: id event
[
]
}
} case
- ]
+ ] ;
- METHOD: char acceptsFirstResponder [ 1 ]
+ METHOD: char acceptsFirstResponder [ 1 ] ;
! Services
METHOD: id validRequestorForSendType: id sendType returnType: id returnType
world-focus sendType returnType
valid-service? [ self ] [ f ] if
] [ f ] if*
- ]
+ ] ;
METHOD: char writeSelectionToPasteboard: id pboard types: id types
[
[ pboard set-pasteboard-string 1 ] [ 0 ] if*
] [ 0 ] if*
] [ 0 ] if
- ]
+ ] ;
METHOD: char readSelectionFromPasteboard: id pboard
[
pboard pasteboard-string
[ window user-input 1 ] [ 0 ] if*
] [ 0 ] if
- ]
+ ] ;
! Text input
METHOD: void insertText: id text
window [
text CF>string window user-input
] when
- ]
+ ] ;
- METHOD: char hasMarkedText [ 0 ]
+ METHOD: char hasMarkedText [ 0 ] ;
- METHOD: NSRange markedRange [ 0 0 <NSRange> ]
+ METHOD: NSRange markedRange [ 0 0 <NSRange> ] ;
- METHOD: NSRange selectedRange [ 0 0 <NSRange> ]
+ METHOD: NSRange selectedRange [ 0 0 <NSRange> ] ;
- METHOD: void setMarkedText: id text selectedRange: NSRange range [ ]
+ METHOD: void setMarkedText: id text selectedRange: NSRange range [ ] ;
- METHOD: void unmarkText [ ]
+ METHOD: void unmarkText [ ] ;
- METHOD: id validAttributesForMarkedText [ NSArray -> array ]
+ METHOD: id validAttributesForMarkedText [ NSArray -> array ] ;
- METHOD: id attributedSubstringFromRange: NSRange range [ f ]
+ METHOD: id attributedSubstringFromRange: NSRange range [ f ] ;
- METHOD: NSUInteger characterIndexForPoint: NSPoint point [ 0 ]
+ METHOD: NSUInteger characterIndexForPoint: NSPoint point [ 0 ] ;
- METHOD: NSRect firstRectForCharacterRange: NSRange range [ 0 0 0 0 <CGRect> ]
+ METHOD: NSRect firstRectForCharacterRange: NSRange range [ 0 0 0 0 <CGRect> ] ;
- METHOD: NSInteger conversationIdentifier [ self alien-address ]
+ METHOD: NSInteger conversationIdentifier [ self alien-address ] ;
! Initialization
METHOD: void updateFactorGadgetSize: id notification
window [
self view-dim window dim<< yield
] when
- ]
+ ] ;
- METHOD: void doCommandBySelector: SEL selector [ ]
+ METHOD: void doCommandBySelector: SEL selector [ ] ;
METHOD: id initWithFrame: NSRect frame pixelFormat: id pixelFormat
[
self frame pixelFormat SUPER-> initWithFrame:pixelFormat:
dup dup add-resize-observer
- ]
+ ] ;
- METHOD: char isOpaque [ 0 ]
+ METHOD: char isOpaque [ 0 ] ;
METHOD: void dealloc
[
self remove-observer
self SUPER-> dealloc
- ]
-]
+ ] ;
+;
: sync-refresh-to-screen ( GLView -- )
-> openGLContext -> CGLContextObj NSOpenGLCPSwapInterval 1 int <ref>
-> frame CGRect-top-left 2array >>window-loc drop ;
CLASS: FactorWindowDelegate < NSObject
-[
+
METHOD: void windowDidMove: id notification
[
notification -> object -> contentView window
[ notification -> object save-position ] when*
- ]
+ ] ;
METHOD: void windowDidBecomeKey: id notification
[
notification -> object -> contentView window
[ focus-world ] when*
- ]
+ ] ;
METHOD: void windowDidResignKey: id notification
[
view -> isInFullScreenMode 0 =
[ window unfocus-world ] when
] when
- ]
+ ] ;
- METHOD: char windowShouldClose: id notification [ 1 ]
+ METHOD: char windowShouldClose: id notification [ 1 ] ;
METHOD: void windowWillClose: id notification
[
notification -> object -> contentView
[ window ungraft ] [ unregister-window ] bi
- ]
+ ] ;
METHOD: void windowDidChangeBackingProperties: id notification
[
[ [ 1.0 > ] keep f ? gl-scale-factor set-global ]
[ 1.0 > retina? set-global ] bi
] [ drop ] if
- ]
-]
+ ] ;
+;
: install-window-delegate ( window -- )
FactorWindowDelegate install-delegate ;