Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSPasteboard.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 | 62202ce0039f |
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.NSPasteboard; | 14 module dwt.internal.cocoa.NSPasteboard; |
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.NSData; | 19 import dwt.internal.cocoa.NSData; |
19 import dwt.internal.cocoa.NSFileWrapper; | |
20 import dwt.internal.cocoa.NSInteger; | |
21 import dwt.internal.cocoa.NSObject; | 20 import dwt.internal.cocoa.NSObject; |
22 import dwt.internal.cocoa.NSString; | 21 import dwt.internal.cocoa.NSString; |
23 import dwt.internal.cocoa.OS; | 22 import dwt.internal.cocoa.OS; |
23 import dwt.internal.objc.cocoa.Cocoa; | |
24 import objc = dwt.internal.objc.runtime; | 24 import objc = dwt.internal.objc.runtime; |
25 | 25 |
26 public class NSPasteboard : NSObject | 26 public class NSPasteboard : NSObject { |
27 { | |
28 | 27 |
29 public this () | 28 public this() { |
30 { | 29 super(); |
31 super(); | 30 } |
32 } | |
33 | 31 |
34 public this (objc.id id) | 32 public this(objc.id id) { |
35 { | 33 super(id); |
36 super(id); | 34 } |
37 } | |
38 | 35 |
39 public NSInteger addTypes (NSArray newTypes, id newOwner) | 36 public this(cocoa.id id) { |
40 { | 37 super(id); |
41 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_addTypes_1owner_1, newTypes !is null ? newTypes.id_ : null, newOwner !is null ? newOwner.id_ : null); | 38 } |
42 } | |
43 | 39 |
44 public NSString availableTypeFromArray (NSArray types) | 40 public NSInteger addTypes(NSArray newTypes, cocoa.id newOwner) { |
45 { | 41 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_addTypes_owner_, newTypes !is null ? newTypes.id : null, newOwner !is null ? newOwner.id : null); |
46 objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableTypeFromArray_1, types !is null ? types.id_ : null); | 42 } |
47 return result !is null ? new NSString(result) : null; | |
48 } | |
49 | 43 |
50 public NSInteger changeCount () | 44 public NSString availableTypeFromArray(NSArray types) { |
51 { | 45 objc.id result = OS.objc_msgSend(this.id, OS.sel_availableTypeFromArray_, types !is null ? types.id : null); |
52 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_changeCount); | 46 return result !is null ? new NSString(result) : null; |
53 } | 47 } |
54 | 48 |
55 public NSData dataForType (NSString dataType) | 49 public NSData dataForType(NSString dataType) { |
56 { | 50 objc.id result = OS.objc_msgSend(this.id, OS.sel_dataForType_, dataType !is null ? dataType.id : null); |
57 objc.id result = OS.objc_msgSend(this.id_, OS.sel_dataForType_1, dataType !is null ? dataType.id_ : null); | 51 return result !is null ? new NSData(result) : null; |
58 return result !is null ? new NSData(result) : null; | 52 } |
59 } | |
60 | 53 |
61 public NSInteger declareTypes (NSArray newTypes, id newOwner) | 54 public NSInteger declareTypes(NSArray newTypes, cocoa.id newOwner) { |
62 { | 55 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_declareTypes_owner_, newTypes !is null ? newTypes.id : null, newOwner !is null ? newOwner.id : null); |
63 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_declareTypes_1owner_1, newTypes !is null ? newTypes.id_ : null, newOwner !is null ? newOwner.id_ : null); | 56 } |
64 } | |
65 | 57 |
66 public static NSPasteboard generalPasteboard () | 58 public static NSPasteboard generalPasteboard() { |
67 { | 59 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_generalPasteboard); |
68 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_generalPasteboard); | 60 return result !is null ? new NSPasteboard(result) : null; |
69 return result !is null ? new NSPasteboard(result) : null; | 61 } |
70 } | |
71 | 62 |
72 public NSString name () | 63 public static NSPasteboard pasteboardWithName(NSString name) { |
73 { | 64 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithName_, name !is null ? name.id : null); |
74 objc.id result = OS.objc_msgSend(this.id_, OS.sel_name); | 65 return result !is null ? new NSPasteboard(result) : null; |
75 return result !is null ? new NSString(result) : null; | 66 } |
76 } | |
77 | 67 |
78 public static NSPasteboard pasteboardByFilteringData (NSData data, NSString type) | 68 public cocoa.id propertyListForType(NSString dataType) { |
79 { | 69 objc.id result = OS.objc_msgSend(this.id, OS.sel_propertyListForType_, dataType !is null ? dataType.id : null); |
80 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringData_1ofType_1, data !is null ? data.id_ : null, | 70 return result !is null ? new id(result) : null; |
81 type !is null ? type.id_ : null); | 71 } |
82 return result !is null ? new NSPasteboard(result) : null; | |
83 } | |
84 | 72 |
85 public static NSPasteboard pasteboardByFilteringFile (NSString filename) | 73 public bool setData(NSData data, NSString dataType) { |
86 { | 74 return OS.objc_msgSend_bool(this.id, OS.sel_setData_forType_, data !is null ? data.id : null, dataType !is null ? dataType.id : null); |
87 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringFile_1, filename !is null ? filename.id_ : null); | 75 } |
88 return result !is null ? new NSPasteboard(result) : null; | |
89 } | |
90 | 76 |
91 public static NSPasteboard pasteboardByFilteringTypesInPasteboard (NSPasteboard pboard) | 77 public bool setPropertyList(cocoa.id plist, NSString dataType) { |
92 { | 78 return OS.objc_msgSend_bool(this.id, OS.sel_setPropertyList_forType_, plist !is null ? plist.id : null, dataType !is null ? dataType.id : null); |
93 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardByFilteringTypesInPasteboard_1, pboard !is null ? pboard.id_ : null); | 79 } |
94 return result !is null ? new NSPasteboard(result) : null; | |
95 } | |
96 | 80 |
97 public static NSPasteboard pasteboardWithName (NSString name) | 81 public bool setString(NSString string, NSString dataType) { |
98 { | 82 return OS.objc_msgSend_bool(this.id, OS.sel_setString_forType_, string !is null ? string.id : null, dataType !is null ? dataType.id : null); |
99 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithName_1, name !is null ? name.id_ : null); | 83 } |
100 return result !is null ? new NSPasteboard(result) : null; | |
101 } | |
102 | 84 |
103 public static NSPasteboard pasteboardWithUniqueName () | 85 public NSString stringForType(NSString dataType) { |
104 { | 86 objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForType_, dataType !is null ? dataType.id : null); |
105 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_pasteboardWithUniqueName); | 87 return result !is null ? new NSString(result) : null; |
106 return result !is null ? new NSPasteboard(result) : null; | 88 } |
107 } | |
108 | 89 |
109 public id propertyListForType (NSString dataType) | 90 public NSArray types() { |
110 { | 91 objc.id result = OS.objc_msgSend(this.id, OS.sel_types); |
111 objc.id result = OS.objc_msgSend(this.id_, OS.sel_propertyListForType_1, dataType !is null ? dataType.id_ : null); | 92 return result !is null ? new NSArray(result) : null; |
112 return result !is null ? new id(result) : null; | 93 } |
113 } | |
114 | |
115 public NSString readFileContentsType (NSString type, NSString filename) | |
116 { | |
117 objc.id result = OS.objc_msgSend(this.id_, OS.sel_readFileContentsType_1toFile_1, type !is null ? type.id_ : null, | |
118 filename !is null ? filename.id_ : null); | |
119 return result !is null ? new NSString(result) : null; | |
120 } | |
121 | |
122 public NSFileWrapper readFileWrapper () | |
123 { | |
124 objc.id result = OS.objc_msgSend(this.id_, OS.sel_readFileWrapper); | |
125 return result !is null ? new NSFileWrapper(result) : null; | |
126 } | |
127 | |
128 public void releaseGlobally () | |
129 { | |
130 OS.objc_msgSend(this.id_, OS.sel_releaseGlobally); | |
131 } | |
132 | |
133 public bool setData (NSData data, NSString dataType) | |
134 { | |
135 return OS.objc_msgSend(this.id_, OS.sel_setData_1forType_1, data !is null ? data.id_ : null, dataType !is null ? dataType.id_ : null) !is null; | |
136 } | |
137 | |
138 public bool setPropertyList (id plist, NSString dataType) | |
139 { | |
140 return OS.objc_msgSend(this.id_, OS.sel_setPropertyList_1forType_1, plist !is null ? plist.id_ : null, dataType !is null ? dataType.id_ : null) !is null; | |
141 } | |
142 | |
143 public bool setString (NSString string, NSString dataType) | |
144 { | |
145 return OS.objc_msgSend(this.id_, OS.sel_setString_1forType_1, string !is null ? string.id_ : null, dataType !is null ? dataType.id_ : null) !is null; | |
146 } | |
147 | |
148 public NSString stringForType (NSString dataType) | |
149 { | |
150 objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringForType_1, dataType !is null ? dataType.id_ : null); | |
151 return result !is null ? new NSString(result) : null; | |
152 } | |
153 | |
154 public NSArray types () | |
155 { | |
156 objc.id result = OS.objc_msgSend(this.id_, OS.sel_types); | |
157 return result !is null ? new NSArray(result) : null; | |
158 } | |
159 | |
160 public static NSArray typesFilterableTo (NSString type) | |
161 { | |
162 objc.id result = OS.objc_msgSend(OS.class_NSPasteboard, OS.sel_typesFilterableTo_1, type !is null ? type.id_ : null); | |
163 return result !is null ? new NSArray(result) : null; | |
164 } | |
165 | |
166 public bool writeFileContents (NSString filename) | |
167 { | |
168 return OS.objc_msgSend(this.id_, OS.sel_writeFileContents_1, filename !is null ? filename.id_ : null) !is null; | |
169 } | |
170 | |
171 public bool writeFileWrapper (NSFileWrapper wrapper) | |
172 { | |
173 return OS.objc_msgSend(this.id_, OS.sel_writeFileWrapper_1, wrapper !is null ? wrapper.id_ : null) !is null; | |
174 } | |
175 | 94 |
176 } | 95 } |