comparison dwt/internal/cocoa/NSValue.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSValue;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSObject;
18 import dwt.internal.cocoa.NSPoint;
19 import dwt.internal.cocoa.NSRange;
20 import dwt.internal.cocoa.NSRect;
21 import dwt.internal.cocoa.NSSize;
22 import dwt.internal.cocoa.OS;
23 import objc = dwt.internal.objc.runtime;
24
25 public class NSValue : NSObject
26 {
27
28 public this ()
29 {
30 super();
31 }
32
33 public this (objc.id id)
34 {
35 super(id);
36 }
37
38 public void getValue (void* value)
39 {
40 OS.objc_msgSend(this.id, OS.sel_getValue_1, value);
41 }
42
43 public id initWithBytes (/*const*/void* value, /*const char* */byte* type)
44 {
45 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytes_1objCType_1, value, type);
46 return result !is null ? new id(result) : null;
47 }
48
49 public bool isEqualToValue (NSValue value)
50 {
51 return OS.objc_msgSend(this.id, OS.sel_isEqualToValue_1, value !is null ? value.id : null) !is null;
52 }
53
54 public id nonretainedObjectValue ()
55 {
56 objc.id result = OS.objc_msgSend(this.id, OS.sel_nonretainedObjectValue);
57 return result !is null ? new id(result) : null;
58 }
59
60 public /*const char* */byte* objCType ()
61 {
62 return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_objCType);
63 }
64
65 public NSPoint pointValue ()
66 {
67 NSPoint result;
68 OS.objc_msgSend_stret(result, this.id, OS.sel_pointValue);
69 return result;
70 }
71
72 public void* pointerValue ()
73 {
74 return cast(void*) OS.objc_msgSend(this.id, OS.sel_pointerValue);
75 }
76
77 public NSRange rangeValue ()
78 {
79 NSRange result;
80 OS.objc_msgSend_stret(result, this.id, OS.sel_rangeValue);
81 return result;
82 }
83
84 public NSRect rectValue ()
85 {
86 NSRect result;
87 OS.objc_msgSend_stret(result, this.id, OS.sel_rectValue);
88 return result;
89 }
90
91 public NSSize sizeValue ()
92 {
93 NSSize result;
94 OS.objc_msgSend_struct(result, this.id, OS.sel_sizeValue);
95 return result;
96 }
97
98 public static NSValue value (/*const*/void* value, /*const char* */byte* type)
99 {
100 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_value_1withObjCType_1, value, type);
101 return result !is null ? new NSValue(result) : null;
102 }
103
104 public static NSValue valueWithBytes (/*const*/void* value, /*const char* */byte* type)
105 {
106 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithBytes_1objCType_1, value, type);
107 return result !is null ? new NSValue(result) : null;
108 }
109
110 public static NSValue valueWithNonretainedObject (id anObject)
111 {
112 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithNonretainedObject_1, anObject !is null ? anObject.id : null);
113 return result !is null ? new NSValue(result) : null;
114 }
115
116 public static NSValue valueWithPoint (NSPoint point)
117 {
118 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPoint_1, point);
119 return result !is null ? new NSValue(result) : null;
120 }
121
122 public static NSValue valueWithPointer (/*const*/void* pointer)
123 {
124 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPointer_1, pointer);
125 return result !is null ? new NSValue(result) : null;
126 }
127
128 public static NSValue valueWithRange (NSRange range)
129 {
130 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRange_1, range);
131 return result !is null ? new NSValue(result) : null;
132 }
133
134 public static NSValue valueWithRect (NSRect rect)
135 {
136 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRect_1, rect);
137 return result !is null ? new NSValue(result) : null;
138 }
139
140 public static NSValue valueWithSize (NSSize size)
141 {
142 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithSize_1, size);
143 return result !is null ? new NSValue(result) : null;
144 }
145
146 }