comparison dwt/widgets/Scale.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 1a8b3cb347e0
children d8635bb48c7c
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
111 return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0); 111 return checkBits (style, DWT.HORIZONTAL, DWT.VERTICAL, 0, 0, 0, 0);
112 } 112 }
113 113
114 public Point computeSize (int wHint, int hHint, bool changed) { 114 public Point computeSize (int wHint, int hHint, bool changed) {
115 checkWidget(); 115 checkWidget();
116 NSSlider widget = (NSSlider)view; 116 NSSlider widget = cast(NSSlider)view;
117 NSRect oldRect = widget.frame(); 117 NSRect oldRect = widget.frame();
118 widget.sizeToFit(); 118 widget.sizeToFit();
119 NSRect newRect = widget.frame(); 119 NSRect newRect = widget.frame();
120 widget.setFrame (oldRect); 120 widget.setFrame (oldRect);
121 int width = 0, height = 0; 121 int width = 0, height = 0;
122 if ((style & DWT.HORIZONTAL) !is 0) { 122 if ((style & DWT.HORIZONTAL) !is 0) {
123 height = (int)newRect.width; 123 height = cast(int)newRect.width;
124 width = height * 10; 124 width = height * 10;
125 } else { 125 } else {
126 width = (int)newRect.width; 126 width = cast(int)newRect.width;
127 height = width * 10; 127 height = width * 10;
128 } 128 }
129 if (wHint !is DWT.DEFAULT) width = wHint; 129 if (wHint !is DWT.DEFAULT) width = wHint;
130 if (hHint !is DWT.DEFAULT) height = hHint; 130 if (hHint !is DWT.DEFAULT) height = hHint;
131 return new Point (width, height); 131 return new Point (width, height);
132 } 132 }
133 133
134 void createHandle () { 134 void createHandle () {
135 NSSlider widget = (NSSlider)new SWTSlider().alloc(); 135 NSSlider widget = cast(NSSlider)new SWTSlider().alloc();
136 NSRect rect = new NSRect(); 136 NSRect rect = new NSRect();
137 if ((style & DWT.HORIZONTAL) !is 0) { 137 if ((style & DWT.HORIZONTAL) !is 0) {
138 rect.width = 1; 138 rect.width = 1;
139 } else { 139 } else {
140 rect.height = 1; 140 rect.height = 1;
173 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 173 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
174 * </ul> 174 * </ul>
175 */ 175 */
176 public int getMaximum () { 176 public int getMaximum () {
177 checkWidget(); 177 checkWidget();
178 return (int)((NSSlider)view).maxValue(); 178 return cast(int)(cast(NSSlider)view).maxValue();
179 } 179 }
180 180
181 /** 181 /**
182 * Returns the minimum value which the receiver will allow. 182 * Returns the minimum value which the receiver will allow.
183 * 183 *
188 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 188 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
189 * </ul> 189 * </ul>
190 */ 190 */
191 public int getMinimum () { 191 public int getMinimum () {
192 checkWidget(); 192 checkWidget();
193 return (int)((NSSlider)view).minValue(); 193 return cast(int)(cast(NSSlider)view).minValue();
194 } 194 }
195 195
196 /** 196 /**
197 * Returns the amount that the receiver's value will be 197 * Returns the amount that the receiver's value will be
198 * modified by when the page increment/decrement areas 198 * modified by when the page increment/decrement areas
226 // if ((style & DWT.VERTICAL) !is 0) { 226 // if ((style & DWT.VERTICAL) !is 0) {
227 // int minimum = OS.GetControl32BitMinimum (handle); 227 // int minimum = OS.GetControl32BitMinimum (handle);
228 // int maximum = OS.GetControl32BitMaximum (handle); 228 // int maximum = OS.GetControl32BitMaximum (handle);
229 // value = maximum - value + minimum; 229 // value = maximum - value + minimum;
230 // } 230 // }
231 return (int)((NSSlider)view).doubleValue(); 231 return cast(int)(cast(NSSlider)view).doubleValue();
232 } 232 }
233 233
234 /** 234 /**
235 * Removes the listener from the collection of listeners who will 235 * Removes the listener from the collection of listeners who will
236 * be notified when the user changes the receiver's value. 236 * be notified when the user changes the receiver's value.
289 * </ul> 289 * </ul>
290 */ 290 */
291 public void setMaximum (int value) { 291 public void setMaximum (int value) {
292 checkWidget(); 292 checkWidget();
293 if (value < 0) return; 293 if (value < 0) return;
294 ((NSSlider)view).setMaxValue(value); 294 (cast(NSSlider)view).setMaxValue(value);
295 } 295 }
296 296
297 /** 297 /**
298 * Sets the minimum value that the receiver will allow. This new 298 * Sets the minimum value that the receiver will allow. This new
299 * value will be ignored if it is negative or is not less than the receiver's 299 * value will be ignored if it is negative or is not less than the receiver's
308 * </ul> 308 * </ul>
309 */ 309 */
310 public void setMinimum (int value) { 310 public void setMinimum (int value) {
311 checkWidget(); 311 checkWidget();
312 if (value < 0) return; 312 if (value < 0) return;
313 ((NSSlider)view).setMinValue(value); 313 (cast(NSSlider)view).setMinValue(value);
314 } 314 }
315 315
316 /** 316 /**
317 * Sets the amount that the receiver's value will be 317 * Sets the amount that the receiver's value will be
318 * modified by when the page increment/decrement areas 318 * modified by when the page increment/decrement areas
343 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 343 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
344 * </ul> 344 * </ul>
345 */ 345 */
346 public void setSelection (int value) { 346 public void setSelection (int value) {
347 checkWidget(); 347 checkWidget();
348 ((NSSlider)view).setDoubleValue(value); 348 (cast(NSSlider)view).setDoubleValue(value);
349 } 349 }
350 350
351 } 351 }