API 0.9.5
AppKit/CPOpenPanel.j
Go to the documentation of this file.
00001 /*
00002  * CPOpenPanel.j
00003  * AppKit
00004  *
00005  * Created by Ross Boucher.
00006  * Copyright 2009, 280 North, Inc.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 
00024 
00025 @implementation CPOpenPanel : CPPanel
00026 {
00027     BOOL    _canChooseFiles;
00028     BOOL    _canChooseDirectories;
00029     BOOL    _allowsMultipleSelection;
00030     CPURL   _directoryURL;
00031     CPArray _URLs;
00032 }
00033 
00034 + (id)openPanel
00035 {
00036     return [[CPOpenPanel alloc] init];
00037 }
00038 
00039 - (CPInteger)runModal
00040 {
00041     if (typeof window["cpOpenPanel"] === "function")
00042     {
00043         // FIXME: Is this correct???
00044         [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
00045 
00046         var options = { directoryURL: [self directoryURL],
00047                         canChooseFiles: [self canChooseFiles],
00048                         canChooseDirectories: [self canChooseDirectories],
00049                         allowsMultipleSelection: [self allowsMultipleSelection] };
00050 
00051         var result = window.cpOpenPanel(options);
00052 
00053         _URLs = result.URLs;
00054 
00055         return result.button;
00056     }
00057 
00058     throw "-runModal is unimplemented.";
00059 }
00060 
00061 - (CPArray)URLs
00062 {
00063     return _URLs;
00064 }
00065 
00066 @end
00067 
00068 @implementation CPOpenPanel (CPSynthesizedAccessors)
00069 
00073 - (BOOL)canChooseFiles
00074 {
00075     return _canChooseFiles;
00076 }
00077 
00081 - (void)setCanChooseFiles:(BOOL)aValue
00082 {
00083     _canChooseFiles = aValue;
00084 }
00085 
00089 - (BOOL)canChooseDirectories
00090 {
00091     return _canChooseDirectories;
00092 }
00093 
00097 - (void)setCanChooseDirectories:(BOOL)aValue
00098 {
00099     _canChooseDirectories = aValue;
00100 }
00101 
00105 - (BOOL)allowsMultipleSelection
00106 {
00107     return _allowsMultipleSelection;
00108 }
00109 
00113 - (void)setAllowsMultipleSelection:(BOOL)aValue
00114 {
00115     _allowsMultipleSelection = aValue;
00116 }
00117 
00121 - (CPURL)directoryURL
00122 {
00123     return _directoryURL;
00124 }
00125 
00129 - (void)setDirectoryURL:(CPURL)aValue
00130 {
00131     _directoryURL = aValue;
00132 }
00133 
00134 @end
 All Classes Files Functions Variables Defines