comparison dwt/internal/cocoa/NSOpenPanel.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSOpenPanel; 14 module dwt.internal.cocoa.NSOpenPanel;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import cocoa = dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSArray; 18 import dwt.internal.cocoa.NSArray;
18 import dwt.internal.cocoa.NSInteger;
19 import dwt.internal.cocoa.NSSavePanel; 19 import dwt.internal.cocoa.NSSavePanel;
20 import dwt.internal.cocoa.NSString;
21 import dwt.internal.cocoa.NSWindow;
22 import dwt.internal.cocoa.OS; 20 import dwt.internal.cocoa.OS;
23 import objc = dwt.internal.objc.runtime; 21 import objc = dwt.internal.objc.runtime;
24 22
25 public class NSOpenPanel : NSSavePanel 23 public class NSOpenPanel : NSSavePanel {
26 {
27 24
28 public this () 25 public this() {
29 { 26 super();
30 super(); 27 }
31 }
32 28
33 public this (objc.id id) 29 public this(objc.id id) {
34 { 30 super(id);
35 super(id); 31 }
36 }
37 32
38 public NSArray URLs () 33 public this(cocoa.id id) {
39 { 34 super(id);
40 objc.id result = OS.objc_msgSend(this.id_, OS.sel_URLs); 35 }
41 return result !is null ? new NSArray(result) : null;
42 }
43 36
44 public bool allowsMultipleSelection () 37 public NSArray filenames() {
45 { 38 objc.id result = OS.objc_msgSend(this.id, OS.sel_filenames);
46 return OS.objc_msgSend(this.id_, OS.sel_allowsMultipleSelection) !is null; 39 return result !is null ? new NSArray(result) : null;
47 } 40 }
48 41
49 public void beginForDirectory (NSString path, NSString name, NSArray fileTypes, id delegatee, objc.SEL didEndSelector, void* contextInfo) 42 public static NSOpenPanel openPanel() {
50 { 43 objc.id result = OS.objc_msgSend(OS.class_NSOpenPanel, OS.sel_openPanel);
51 OS.objc_msgSend(this.id_, OS.sel_beginForDirectory_1file_1types_1modelessDelegate_1didEndSelector_1contextInfo_1, 44 return result !is null ? new NSOpenPanel(result) : null;
52 path !is null ? path.id_ : null, name !is null ? name.id_ : null, fileTypes !is null ? fileTypes.id_ : null, 45 }
53 delegatee !is null ? delegatee.id_ : null, didEndSelector, contextInfo);
54 }
55 46
56 public void beginSheetForDirectory (NSString path, NSString name, NSArray fileTypes, NSWindow docWindow, id delegatee, objc.SEL didEndSelector, 47 public void setAllowsMultipleSelection(bool flag) {
57 void* contextInfo) 48 OS.objc_msgSend(this.id, OS.sel_setAllowsMultipleSelection_, flag);
58 { 49 }
59 OS.objc_msgSend(this.id_, OS.sel_beginSheetForDirectory_1file_1types_1modalForWindow_1modalDelegate_1didEndSelector_1contextInfo_1,
60 path !is null ? path.id_ : null, name !is null ? name.id_ : null, fileTypes !is null ? fileTypes.id_ : null,
61 docWindow !is null ? docWindow.id_ : null, delegatee !is null ? delegatee.id_ : null, didEndSelector, contextInfo);
62 }
63 50
64 public bool canChooseDirectories () 51 public void setCanChooseDirectories(bool flag) {
65 { 52 OS.objc_msgSend(this.id, OS.sel_setCanChooseDirectories_, flag);
66 return OS.objc_msgSend(this.id_, OS.sel_canChooseDirectories) !is null; 53 }
67 }
68 54
69 public bool canChooseFiles () 55 public void setCanChooseFiles(bool flag) {
70 { 56 OS.objc_msgSend(this.id, OS.sel_setCanChooseFiles_, flag);
71 return OS.objc_msgSend(this.id_, OS.sel_canChooseFiles) !is null; 57 }
72 }
73 58
74 public NSArray filenames () 59 public static NSSavePanel savePanel() {
75 { 60 objc.id result = OS.objc_msgSend(OS.class_NSOpenPanel, OS.sel_savePanel);
76 objc.id result = OS.objc_msgSend(this.id_, OS.sel_filenames); 61 return result !is null ? new NSSavePanel(result) : null;
77 return result !is null ? new NSArray(result) : null; 62 }
78 }
79
80 public static NSOpenPanel openPanel ()
81 {
82 objc.id result = OS.objc_msgSend(OS.class_NSOpenPanel, OS.sel_openPanel);
83 return result !is null ? new NSOpenPanel(result) : null;
84 }
85
86 public bool resolvesAliases ()
87 {
88 return OS.objc_msgSend(this.id_, OS.sel_resolvesAliases) !is null;
89 }
90
91 public NSInteger runModalForDirectory (NSString path, NSString name, NSArray fileTypes)
92 {
93 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_runModalForDirectory_1file_1types_1, path !is null ? path.id_ : null, name !is null ? name.id_ : null,
94 fileTypes !is null ? fileTypes.id_ : null);
95 }
96
97 public NSInteger runModalForTypes (NSArray fileTypes)
98 {
99 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_runModalForTypes_1, fileTypes !is null ? fileTypes.id_ : null);
100 }
101
102 public void setAllowsMultipleSelection (bool flag)
103 {
104 OS.objc_msgSend(this.id_, OS.sel_setAllowsMultipleSelection_1, flag);
105 }
106
107 public void setCanChooseDirectories (bool flag)
108 {
109 OS.objc_msgSend(this.id_, OS.sel_setCanChooseDirectories_1, flag);
110 }
111
112 public void setCanChooseFiles (bool flag)
113 {
114 OS.objc_msgSend(this.id_, OS.sel_setCanChooseFiles_1, flag);
115 }
116
117 public void setResolvesAliases (bool flag)
118 {
119 OS.objc_msgSend(this.id_, OS.sel_setResolvesAliases_1, flag);
120 }
121 63
122 } 64 }