comparison dwt/widgets/Composite.d @ 22:c6edc6e9bd0d

Ported dwt.widgets.Composite
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sun, 07 Sep 2008 22:19:25 +0200
parents a9ab4c738ed8
children db5a898b2119
comparison
equal deleted inserted replaced
21:fdbd69a5f101 22:c6edc6e9bd0d
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 <jacob.carlborg@gmail.com>
10 *******************************************************************************/ 13 *******************************************************************************/
11 module dwt.widgets.Composite; 14 module dwt.widgets.Composite;
12
13 import dwt.dwthelper.utils;
14 15
15 16
16 import dwt.DWT; 17 import dwt.DWT;
17 import dwt.DWTException; 18 import dwt.DWTException;
18 import dwt.graphics.Point; 19 import dwt.graphics.Point;
22 import dwt.internal.cocoa.NSRect; 23 import dwt.internal.cocoa.NSRect;
23 import dwt.internal.cocoa.NSView; 24 import dwt.internal.cocoa.NSView;
24 import dwt.internal.cocoa.OS; 25 import dwt.internal.cocoa.OS;
25 import dwt.internal.cocoa.SWTScrollView; 26 import dwt.internal.cocoa.SWTScrollView;
26 import dwt.internal.cocoa.SWTView; 27 import dwt.internal.cocoa.SWTView;
28
29 import dwt.dwthelper.utils;
30 import dwt.internal.cocoa.NSInteger;
31 import dwt.widgets.Control;
32 import dwt.widgets.Decorations;
33 import dwt.widgets.Display;
34 import dwt.widgets.Event;
35 import dwt.widgets.Layout;
36 import dwt.widgets.Menu;
37 import dwt.widgets.Scrollable;
38 import dwt.widgets.ScrollBar;
39 import dwt.widgets.Shell;
40 import dwt.widgets.Widget;
41
27 42
28 /** 43 /**
29 * Instances of this class are controls which are capable 44 * Instances of this class are controls which are capable
30 * of containing other controls. 45 * of containing other controls.
31 * <dl> 46 * <dl>
98 super (parent, style); 113 super (parent, style);
99 } 114 }
100 115
101 Control [] _getChildren () { 116 Control [] _getChildren () {
102 NSArray views = contentView().subviews(); 117 NSArray views = contentView().subviews();
103 int count = views.count(); 118 NSUInteger count = views.count();
104 Control [] children = new Control [count]; 119 Control [] children = new Control [count];
105 int j = 0; 120 int j = 0;
106 for (int i=0; i<count; i++){ 121 for (int i=0; i<count; i++){
107 int tag = new NSView(views.objectAtIndex(i)).tag(); 122 NSInteger tag = (new NSView(views.objectAtIndex(i))).tag();
108 if (tag !is 0 && tag !is -1) { 123 if (tag !is 0 && tag !is -1) {
109 Object widget = OS.JNIGetObject(tag); 124 Object widget = OS.JNIGetObject(tag);
110 if (widget !is null && widget !is this) { 125 if (widget !is null && widget !is this) {
111 if ( null !is cast(Control)widget ) { 126 if ( null !is cast(Control)widget ) {
112 children [j++] = cast(Control) widget; 127 children [j++] = cast(Control) widget;
244 createHandle (parent.contentView()); 259 createHandle (parent.contentView());
245 } 260 }
246 261
247 void createHandle (NSView parent) { 262 void createHandle (NSView parent) {
248 state |= CANVAS; 263 state |= CANVAS;
249 NSRect rect = new NSRect(); 264 NSRect rect = NSRect();
250 if ((style & (DWT.V_SCROLL | DWT.H_SCROLL)) !is 0 || hasBorder ()) { 265 if ((style & (DWT.V_SCROLL | DWT.H_SCROLL)) !is 0 || hasBorder ()) {
251 SWTScrollView scrollWidget = cast(SWTScrollView)new SWTScrollView().alloc(); 266 SWTScrollView scrollWidget = cast(SWTScrollView)(new SWTScrollView()).alloc();
252 scrollWidget.initWithFrame (rect); 267 scrollWidget.initWithFrame (rect);
253 scrollWidget.setDrawsBackground(false); 268 scrollWidget.setDrawsBackground(false);
254 if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true); 269 if ((style & DWT.H_SCROLL) !is 0) scrollWidget.setHasHorizontalScroller(true);
255 if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true); 270 if ((style & DWT.V_SCROLL) !is 0) scrollWidget.setHasVerticalScroller(true);
256 scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder); 271 scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder);
257 scrollWidget.setTag(jniRef); 272 scrollWidget.setTag(jniRef);
258 scrollView = scrollWidget; 273 scrollView = scrollWidget;
259 rect.width = rect.height = 100000; 274 rect.width = rect.height = 100000;
260 } 275 }
261 SWTView widget = cast(SWTView)new SWTView().alloc(); 276 SWTView widget = cast(SWTView)(new SWTView()).alloc();
262 widget.initWithFrame (rect); 277 widget.initWithFrame (rect);
263 // widget.setFocusRingType(OS.NSFocusRingTypeExterior); 278 // widget.setFocusRingType(OS.NSFocusRingTypeExterior);
264 widget.setTag(jniRef); 279 widget.setTag(jniRef);
265 view = widget; 280 view = widget;
266 if (scrollView !is null) { 281 if (scrollView !is null) {