Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSBox.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.NSBox; | 14 module dwt.internal.cocoa.NSBox; |
15 | 15 |
16 import dwt.internal.cocoa.CGFloat; | 16 import dwt.internal.c.Carbon; |
17 import cocoa = dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSCell; | 18 import dwt.internal.cocoa.NSCell; |
18 import dwt.internal.cocoa.NSColor; | 19 import dwt.internal.cocoa.NSColor; |
19 import dwt.internal.cocoa.NSFont; | 20 import dwt.internal.cocoa.NSFont; |
20 import dwt.internal.cocoa.NSInteger; | |
21 import dwt.internal.cocoa.NSRect; | 21 import dwt.internal.cocoa.NSRect; |
22 import dwt.internal.cocoa.NSSize; | 22 import dwt.internal.cocoa.NSSize; |
23 import dwt.internal.cocoa.NSString; | 23 import dwt.internal.cocoa.NSString; |
24 import dwt.internal.cocoa.NSView; | 24 import dwt.internal.cocoa.NSView; |
25 import dwt.internal.cocoa.OS; | 25 import dwt.internal.cocoa.OS; |
26 import dwt.internal.objc.cocoa.Cocoa; | |
26 import objc = dwt.internal.objc.runtime; | 27 import objc = dwt.internal.objc.runtime; |
27 | 28 |
28 alias NSUInteger NSBoxType; | 29 alias NSUInteger NSBoxType; |
29 | 30 |
30 enum | 31 enum { |
31 { | |
32 NSBoxPrimary = 0, | 32 NSBoxPrimary = 0, |
33 NSBoxSecondary = 1, | 33 NSBoxSecondary = 1, |
34 NSBoxSeparator = 2, | 34 NSBoxSeparator = 2, |
35 NSBoxOldStyle = 3, | 35 NSBoxOldStyle = 3, |
36 NSBoxCustom = 4 | 36 NSBoxCustom = 4 |
37 } | 37 } |
38 | 38 |
39 enum NSTitlePosition | 39 enum NSTitlePosition { |
40 { | |
41 NSNoTitle = 0, | 40 NSNoTitle = 0, |
42 NSAboveTop = 1, | 41 NSAboveTop = 1, |
43 NSAtTop = 2, | 42 NSAtTop = 2, |
44 NSBelowTop = 3, | 43 NSBelowTop = 3, |
45 NSAboveBottom = 4, | 44 NSAboveBottom = 4, |
46 NSAtBottom = 5, | 45 NSAtBottom = 5, |
47 NSBelowBottom = 6 | 46 NSBelowBottom = 6 |
48 } | 47 } |
49 | 48 |
50 public class NSBox : NSView | 49 public class NSBox : NSView { |
51 { | 50 |
52 public this () | 51 public this () { |
53 { | 52 super(); |
54 super(); | 53 } |
55 } | |
56 | 54 |
57 public this (objc.id id) | 55 public this (objc.id id) { |
58 { | 56 super(id); |
59 super(id); | 57 } |
60 } | |
61 | 58 |
62 public NSColor borderColor () | 59 public this (cocoa.id id) { |
63 { | 60 super(id); |
64 objc.id result = OS.objc_msgSend(this.id_, OS.sel_borderColor); | 61 } |
65 return result !is null ? new NSColor(result) : null; | |
66 } | |
67 | 62 |
68 public NSRect borderRect () | 63 public CGFloat borderWidth () { |
69 { | 64 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_borderWidth); |
70 NSRect result; | 65 } |
71 OS.objc_msgSend_stret(&result, this.id_, OS.sel_borderRect); | |
72 return result; | |
73 } | |
74 | 66 |
75 public NSBorderType borderType () | 67 public NSSize contentViewMargins () { |
76 { | 68 NSSize result; |
77 return cast(NSBorderType) OS.objc_msgSend(this.id_, OS.sel_borderType); | 69 OS.objc_msgSend_stret(result, this.id, OS.sel_contentViewMargins); |
78 } | 70 return result; |
71 } | |
79 | 72 |
80 public CGFloat borderWidth () | 73 public void setBorderType (NSBorderType aType) { |
81 { | 74 OS.objc_msgSend(this.id, OS.sel_setBorderType_1, aType); |
82 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_borderWidth); | 75 } |
83 } | |
84 | 76 |
85 public NSBoxType boxType () | 77 public void setBorderWidth (CGFloat borderWidth) { |
86 { | 78 OS.objc_msgSend(this.id, OS.sel_setBorderWidth_1, borderWidth); |
87 return cast(NSBoxType) OS.objc_msgSend(this.id_, OS.sel_boxType); | 79 } |
88 } | |
89 | 80 |
90 public NSView contentView () | 81 public void setBoxType (NSBoxType boxType) { |
91 { | 82 OS.objc_msgSend(this.id, OS.sel_setBoxType_1, boxType); |
92 objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentView); | 83 } |
93 return result !is null ? new NSView(result) : null; | |
94 } | |
95 | 84 |
96 public NSSize contentViewMargins () | 85 public void setContentView (NSView aView) { |
97 { | 86 OS.objc_msgSend(this.id, OS.sel_setContentView_, aView !is null ? aView.id : null); |
98 NSSize result; | 87 } |
99 OS.objc_msgSend_stret(&result, this.id_, OS.sel_contentViewMargins); | |
100 return result; | |
101 } | |
102 | 88 |
103 public CGFloat cornerRadius () | 89 public void setContentViewMargins (NSSize offsetSize) { |
104 { | 90 OS.objc_msgSend(this.id, OS.sel_setContentViewMargins_, offsetSize); |
105 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_cornerRadius); | 91 } |
106 } | |
107 | 92 |
108 public NSColor fillColor () | 93 public void setTitle (NSString aString) { |
109 { | 94 OS.objc_msgSend(this.id, OS.sel_setTitle_, aString !is null ? aString.id : null); |
110 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fillColor); | 95 } |
111 return result !is null ? new NSColor(result) : null; | |
112 } | |
113 | 96 |
114 public bool isTransparent () | 97 public void setTitleFont (NSFont fontObj) { |
115 { | 98 OS.objc_msgSend(this.id, OS.sel_setTitleFont_, fontObj !is null ? fontObj.id : null); |
116 return OS.objc_msgSend(this.id_, OS.sel_isTransparent) !is null; | 99 } |
117 } | |
118 | 100 |
119 public void setBorderColor (NSColor borderColor) | 101 public void setTitlePosition (NSTitlePosition aPosition) { |
120 { | 102 OS.objc_msgSend(this.id, OS.sel_setTitlePosition_, aPosition); |
121 OS.objc_msgSend(this.id_, OS.sel_setBorderColor_1, borderColor !is null ? borderColor.id_ : null); | 103 } |
122 } | |
123 | 104 |
124 public void setBorderType (NSBorderType aType) | 105 public void sizeToFit () { |
125 { | 106 OS.objc_msgSend(this.id, OS.sel_sizeToFit); |
126 OS.objc_msgSend(this.id_, OS.sel_setBorderType_1, aType); | 107 } |
127 } | |
128 | 108 |
129 public void setBorderWidth (CGFloat borderWidth) | 109 public NSCell titleCell () { |
130 { | 110 objc.id result = OS.objc_msgSend(this.id, OS.sel_titleCell); |
131 OS.objc_msgSend(this.id_, OS.sel_setBorderWidth_1, borderWidth); | 111 return result !is null ? new NSCell(result) : null; |
132 } | |
133 | |
134 public void setBoxType (NSBoxType boxType) | |
135 { | |
136 OS.objc_msgSend(this.id_, OS.sel_setBoxType_1, boxType); | |
137 } | |
138 | |
139 public void setContentView (NSView aView) | |
140 { | |
141 OS.objc_msgSend(this.id_, OS.sel_setContentView_1, aView !is null ? aView.id_ : null); | |
142 } | |
143 | |
144 public void setContentViewMargins (NSSize offsetSize) | |
145 { | |
146 OS.objc_msgSend(this.id_, OS.sel_setContentViewMargins_1, offsetSize); | |
147 } | |
148 | |
149 public void setCornerRadius (CGFloat cornerRadius) | |
150 { | |
151 OS.objc_msgSend(this.id_, OS.sel_setCornerRadius_1, cornerRadius); | |
152 } | |
153 | |
154 public void setFillColor (NSColor fillColor) | |
155 { | |
156 OS.objc_msgSend(this.id_, OS.sel_setFillColor_1, fillColor !is null ? fillColor.id_ : null); | |
157 } | |
158 | |
159 public void setFrameFromContentFrame (NSRect contentFrame) | |
160 { | |
161 OS.objc_msgSend(this.id_, OS.sel_setFrameFromContentFrame_1, contentFrame); | |
162 } | |
163 | |
164 public void setTitle (NSString aString) | |
165 { | |
166 OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null); | |
167 } | |
168 | |
169 public void setTitleFont (NSFont fontObj) | |
170 { | |
171 OS.objc_msgSend(this.id_, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id_ : null); | |
172 } | |
173 | |
174 public void setTitlePosition (NSTitlePosition aPosition) | |
175 { | |
176 OS.objc_msgSend(this.id_, OS.sel_setTitlePosition_1, aPosition); | |
177 } | |
178 | |
179 public void setTitleWithMnemonic (NSString StringWithAmpersand) | |
180 { | |
181 OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null); | |
182 } | |
183 | |
184 public void setTransparent (bool flag) | |
185 { | |
186 OS.objc_msgSend(this.id_, OS.sel_setTransparent_1, flag); | |
187 } | |
188 | |
189 public void sizeToFit () | |
190 { | |
191 OS.objc_msgSend(this.id_, OS.sel_sizeToFit); | |
192 } | |
193 | |
194 public NSString title () | |
195 { | |
196 objc.id result = OS.objc_msgSend(this.id_, OS.sel_title); | |
197 return result !is null ? new NSString(result) : null; | |
198 } | |
199 | |
200 public NSCell titleCell () | |
201 { | |
202 objc.id result = OS.objc_msgSend(this.id_, OS.sel_titleCell); | |
203 return result !is null ? new NSCell(result) : null; | |
204 } | |
205 | |
206 public NSFont titleFont () | |
207 { | |
208 objc.id result = OS.objc_msgSend(this.id_, OS.sel_titleFont); | |
209 return result !is null ? new NSFont(result) : null; | |
210 } | |
211 | |
212 public NSTitlePosition titlePosition () | |
213 { | |
214 return cast(NSTitlePosition) OS.objc_msgSend(this.id_, OS.sel_titlePosition); | |
215 } | |
216 | |
217 public NSRect titleRect () | |
218 { | |
219 NSRect result; | |
220 OS.objc_msgSend_stret(&result, this.id_, OS.sel_titleRect); | |
221 return result; | |
222 } | |
223 } | 112 } |
113 } |