comparison dwt/widgets/Slider.d @ 76:3f1bfbd329c0

Ported dwt.widgets.Slider
author Jacob Carlborg <doob@me.com>
date Wed, 24 Dec 2008 12:32:20 +0100
parents cfa563df4fdd
children c7f7f4d7091a
comparison
equal deleted inserted replaced
75:1926e6c4bf87 76:3f1bfbd329c0
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 *
11 * Port to the D programming language:
12 * Jacob Carlborg <doob@me.com>
10 *******************************************************************************/ 13 *******************************************************************************/
11 module dwt.widgets.Slider; 14 module dwt.widgets.Slider;
12 15
13 import dwt.dwthelper.utils; 16 import dwt.dwthelper.utils;
14 17
20 import dwt.graphics.Point; 23 import dwt.graphics.Point;
21 import dwt.internal.cocoa.NSRect; 24 import dwt.internal.cocoa.NSRect;
22 import dwt.internal.cocoa.NSScroller; 25 import dwt.internal.cocoa.NSScroller;
23 import dwt.internal.cocoa.OS; 26 import dwt.internal.cocoa.OS;
24 import dwt.internal.cocoa.SWTScroller; 27 import dwt.internal.cocoa.SWTScroller;
28
29 import dwt.widgets.Composite;
30 import dwt.widgets.Control;
31 import dwt.widgets.Event;
32 import dwt.widgets.TypedListener;
25 33
26 /** 34 /**
27 * Instances of this class are selectable user interface 35 * Instances of this class are selectable user interface
28 * objects that represent a range of positive, numeric values. 36 * objects that represent a range of positive, numeric values.
29 * <p> 37 * <p>
171 if (hHint !is DWT.DEFAULT) height = hHint; 179 if (hHint !is DWT.DEFAULT) height = hHint;
172 return new Point (width, height); 180 return new Point (width, height);
173 } 181 }
174 182
175 void createHandle () { 183 void createHandle () {
176 NSScroller widget = cast(NSScroller)new SWTScroller().alloc(); 184 NSScroller widget = cast(NSScroller)(new SWTScroller()).alloc();
177 NSRect rect = NSRect(); 185 NSRect rect = NSRect();
178 if ((style & DWT.HORIZONTAL) !is 0) { 186 if ((style & DWT.HORIZONTAL) !is 0) {
179 rect.width = 1; 187 rect.width = 1;
180 } else { 188 } else {
181 rect.height = 1; 189 rect.height = 1;
316 eventTable.unhook(DWT.DefaultSelection,listener); 324 eventTable.unhook(DWT.DefaultSelection,listener);
317 } 325 }
318 326
319 void sendSelection () { 327 void sendSelection () {
320 Event event = new Event(); 328 Event event = new Event();
321 int hitPart = cast(int)/*64*/((NSScroller)view).hitPart(); 329 NSScrollerPart hitPart = (cast(NSScroller)view).hitPart();
322 int value = getSelection (); 330 int value = getSelection ();
323 switch (hitPart) { 331 switch (hitPart) {
324 case OS.NSScrollerDecrementLine: 332 case OS.NSScrollerDecrementLine:
325 event.detail = DWT.ARROW_UP; 333 event.detail = DWT.ARROW_UP;
326 value -= increment; 334 value -= increment;
338 event.detail = DWT.ARROW_DOWN; 346 event.detail = DWT.ARROW_DOWN;
339 break; 347 break;
340 case OS.NSScrollerKnob: 348 case OS.NSScrollerKnob:
341 event.detail = DWT.DRAG; 349 event.detail = DWT.DRAG;
342 break; 350 break;
351 default:
343 } 352 }
344 if (event.detail !is DWT.DRAG) { 353 if (event.detail !is DWT.DRAG) {
345 setSelection(value); 354 setSelection(value);
346 } 355 }
347 sendEvent(DWT.Selection, event); 356 sendEvent(DWT.Selection, event);