dup 1 -> setResolvesAliases:
dup 1 -> setAllowsMultipleSelection: ;
+: <NSSavePanel> ( -- panel )
+ NSSavePanel -> savePanel
+ dup 1 -> setCanChooseFiles:
+ dup 0 -> setCanChooseDirectories:
+ dup 0 -> setAllowsMultipleSelection: ;
+
: NSOKButton 1 ;
: NSCancelButton 0 ;
+: run-panel ( panel -- paths ) ;
+
: open-panel ( -- paths )
- <NSOpenPanel> dup f -> runModalForTypes: NSOKButton =
+ <NSOpenPanel>
+ dup -> runModal NSOKButton =
[ -> filenames CF>string-array ] [ drop f ] if ;
+
+: split-path ( path -- dir file )
+ <reversed> "/" split1 [ reverse <NSString> ] 2apply swap ;
+
+: save-panel ( path -- paths )
+ <NSSavePanel> dup
+ rot split-path -> runModalForDirectory:file: NSOKButton =
+ [ -> filename CF>string ] [ drop f ] if ;
: menu-run-files ( -- )
open-panel [ listener-run-files ] when* ;
+: menu-save-image ( -- )
+ image save-panel [ save-image ] when* ;
+
! Handle Open events from the Finder
"NSObject" "FactorApplicationDelegate" {
{ "application:openFiles:" "void" { "id" "SEL" "id" "id" }
[ >r 3drop r> finder-run-files ]
}
+ { "newFactorWorkspace:" "id" { "id" "SEL" "id" }
+ [ 3drop workspace-window f ]
+ }
+
{ "runFactorFile:" "id" { "id" "SEL" "id" }
[ 3drop menu-run-files f ]
}
- { "newFactorWorkspace:" "id" { "id" "SEL" "id" }
- [ 3drop workspace-window f ]
+ { "saveFactorImage:" "id" { "id" "SEL" "id" }
+ [ 3drop save f ]
+ }
+
+ { "saveFactorImageAs:" "id" { "id" "SEL" "id" }
+ [ 3drop menu-save-image f ]
}
{ "showFactorHelp:" "id" { "id" "SEL" "id" }