comparison dwt/internal/cocoa/NSValue.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.NSValue; 14 module dwt.internal.cocoa.NSValue;
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.NSObject; 18 import dwt.internal.cocoa.NSObject;
18 import dwt.internal.cocoa.NSPoint; 19 import dwt.internal.cocoa.NSPoint;
20 import dwt.internal.cocoa.NSRect;
19 import dwt.internal.cocoa.NSRange; 21 import dwt.internal.cocoa.NSRange;
20 import dwt.internal.cocoa.NSRect;
21 import dwt.internal.cocoa.NSSize; 22 import dwt.internal.cocoa.NSSize;
22 import dwt.internal.cocoa.OS; 23 import dwt.internal.cocoa.OS;
23 import objc = dwt.internal.objc.runtime; 24 import objc = dwt.internal.objc.runtime;
24 25
25 public class NSValue : NSObject 26 public class NSValue : NSObject {
26 {
27 27
28 public this () 28 public this() {
29 { 29 super();
30 super(); 30 }
31 }
32 31
33 public this (objc.id id) 32 public this(objc.id id) {
34 { 33 super(id);
35 super(id); 34 }
36 }
37 35
38 public void getValue (void* value) 36 public this(cocoa.id id) {
39 { 37 super(id);
40 OS.objc_msgSend(this.id_, OS.sel_getValue_1, value); 38 }
41 }
42 39
43 public id initWithBytes (/*const*/void* value, /*const char* */byte* type) 40 public NSPoint pointValue() {
44 { 41 NSPoint result = NSPoint();
45 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytes_1objCType_1, value, type); 42 OS.objc_msgSend_stret(result, this.id, OS.sel_pointValue);
46 return result !is null ? new id(result) : null; 43 return result;
47 } 44 }
48 45
49 public bool isEqualToValue (NSValue value) 46 public NSRange rangeValue() {
50 { 47 NSRange result = NSRange();
51 return OS.objc_msgSend(this.id_, OS.sel_isEqualToValue_1, value !is null ? value.id_ : null) !is null; 48 OS.objc_msgSend_stret(result, this.id, OS.sel_rangeValue);
52 } 49 return result;
50 }
53 51
54 public id nonretainedObjectValue () 52 public NSSize sizeValue() {
55 { 53 NSSize result = NSSize();
56 objc.id result = OS.objc_msgSend(this.id_, OS.sel_nonretainedObjectValue); 54 OS.objc_msgSend_stret(result, this.id, OS.sel_sizeValue);
57 return result !is null ? new id(result) : null; 55 return result;
58 } 56 }
59 57
60 public /*const char* */byte* objCType () 58 public static NSValue valueWithPoint(NSPoint point) {
61 { 59 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPoint_, point);
62 return cast(/*const char* */byte*) OS.objc_msgSend(this.id_, OS.sel_objCType); 60 return result !is null ? new NSValue(result) : null;
63 } 61 }
64 62
65 public NSPoint pointValue () 63 public static NSValue valueWithRange(NSRange range) {
66 { 64 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRange_, range);
67 NSPoint result; 65 return result !is null ? new NSValue(result) : null;
68 OS.objc_msgSend_stret(&result, this.id_, OS.sel_pointValue); 66 }
69 return result;
70 }
71 67
72 public void* pointerValue () 68 public static NSValue valueWithRect(NSRect rect) {
73 { 69 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRect_, rect);
74 return cast(void*) OS.objc_msgSend(this.id_, OS.sel_pointerValue); 70 return result !is null ? new NSValue(result) : null;
75 } 71 }
76 72
77 public NSRange rangeValue () 73 public static NSValue valueWithSize(NSSize size) {
78 { 74 objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithSize_, size);
79 NSRange result; 75 return result !is null ? new NSValue(result) : null;
80 OS.objc_msgSend_stret(&result, this.id_, OS.sel_rangeValue); 76 }
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 77
146 } 78 }