comparison dwt/widgets/Control.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents 642f460a0908
children cfa563df4fdd
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2000, 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.widgets.Control; 14 module dwt.widgets.Control;
15 15
16 16
17 import dwt.DWT; 17 import dwt.DWT;
18 import dwt.DWTException; 18 import dwt.DWTException;
19 import dwt.accessibility.ACC;
19 import dwt.accessibility.Accessible; 20 import dwt.accessibility.Accessible;
20 import dwt.events.ControlListener; 21 import dwt.events.ControlListener;
21 import dwt.events.DragDetectListener; 22 import dwt.events.DragDetectListener;
22 import dwt.events.FocusListener; 23 import dwt.events.FocusListener;
23 import dwt.events.HelpListener; 24 import dwt.events.HelpListener;
38 import dwt.graphics.GCData; 39 import dwt.graphics.GCData;
39 import dwt.graphics.Image; 40 import dwt.graphics.Image;
40 import dwt.graphics.Point; 41 import dwt.graphics.Point;
41 import dwt.graphics.Rectangle; 42 import dwt.graphics.Rectangle;
42 import dwt.graphics.Region; 43 import dwt.graphics.Region;
44 import dwt.internal.cocoa.NSApplication;
45 import dwt.internal.cocoa.NSArray;
46 import dwt.internal.cocoa.NSAttributedString;
47 import dwt.internal.cocoa.NSBezierPath;
48 import dwt.internal.cocoa.NSColor;
43 import dwt.internal.cocoa.NSControl; 49 import dwt.internal.cocoa.NSControl;
50 import dwt.internal.cocoa.NSDate;
44 import dwt.internal.cocoa.NSEvent; 51 import dwt.internal.cocoa.NSEvent;
45 import dwt.internal.cocoa.NSFont; 52 import dwt.internal.cocoa.NSFont;
46 import dwt.internal.cocoa.NSGraphicsContext; 53 import dwt.internal.cocoa.NSGraphicsContext;
54 import dwt.internal.cocoa.NSInputManager;
55 import dwt.internal.cocoa.NSMutableArray;
47 import dwt.internal.cocoa.NSPoint; 56 import dwt.internal.cocoa.NSPoint;
48 import dwt.internal.cocoa.NSRect; 57 import dwt.internal.cocoa.NSRect;
49 import dwt.internal.cocoa.NSSize; 58 import dwt.internal.cocoa.NSSize;
50 import dwt.internal.cocoa.NSString; 59 import dwt.internal.cocoa.NSString;
51 import dwt.internal.cocoa.NSView; 60 import dwt.internal.cocoa.NSView;
52 import dwt.internal.cocoa.NSWindow;
53 import dwt.internal.cocoa.OS; 61 import dwt.internal.cocoa.OS;
54 import dwt.internal.cocoa.objc_super; 62 import dwt.internal.cocoa.id;
55 63
56 import tango.core.Thread; 64 import tango.core.Thread;
57 65
58 import dwt.dwthelper.utils; 66 import dwt.dwthelper.utils;
59 import dwt.dwthelper.System; 67 import dwt.dwthelper.System;
87 * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified. 95 * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
88 * </p><p> 96 * </p><p>
89 * IMPORTANT: This class is intended to be subclassed <em>only</em> 97 * IMPORTANT: This class is intended to be subclassed <em>only</em>
90 * within the DWT implementation. 98 * within the DWT implementation.
91 * </p> 99 * </p>
100 *
101 * @see <a href="http://www.eclipse.org/swt/snippets/#control">Control snippets</a>
102 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a>
103 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
92 */ 104 */
93 public abstract class Control : Widget , Drawable { 105 public abstract class Control : Widget , Drawable {
94 106
95 alias Widget.setInputState setInputState; 107 alias Widget.setInputState setInputState;
96 108
157 super (parent, style); 169 super (parent, style);
158 this.parent = parent; 170 this.parent = parent;
159 createWidget (); 171 createWidget ();
160 } 172 }
161 173
162 bool acceptsFirstResponder () { 174 int accessibilityActionNames(int /*long*/ id, int /*long*/ sel) {
163 objc_super super_struct = objc_super(); 175 if (accessible !is null) {
164 super_struct.receiver = view.id_; 176 NSArray returnValue = accessible.internal_accessibilityActionNames(ACC.CHILDID_SELF);
165 super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass); 177 if (returnValue !is null) return returnValue.id_;
166 return OS.objc_msgSendSuper(&super_struct, OS.sel_acceptsFirstResponder) !is null; 178 }
167 } 179
168 180 return super.accessibilityActionNames(id, sel);
169 bool becomeFirstResponder () { 181 }
170 //TODO - query focusControl() in DWT.FocusIn/Out is the control 182
171 sendEvent (DWT.FocusIn); 183 int accessibilityAttributeNames(objc.id id, objc.SEL sel) {
172 objc_super super_struct = objc_super(); 184
173 super_struct.receiver = view.id_; 185 if (id is view.id_ || (cast(NSControl)view && (cast(NSControl)view).cell() !is null && (cast(NSControl)view).cell().id_ is id)) {
174 super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass); 186 if (accessible !is null) {
175 return OS.objc_msgSendSuper(&super_struct, OS.sel_becomeFirstResponder) !is null; 187
176 } 188 // First, see if the accessible is going to define a set of attributes for the control.
177 189 // If it does, return that.
178 bool resignFirstResponder () { 190 NSArray returnValue = accessible.internal_accessibilityAttributeNames(ACC.CHILDID_SELF);
179 //TODO - query focusControl() in DWT.FocusIn/Out is the control 191 if (returnValue !is null) return returnValue.id;
180 sendEvent (DWT.FocusOut); 192
181 objc_super super_struct = objc_super(); 193 // If not, see if it will override or augment the standard list.
182 super_struct.receiver = view.id_; 194 // Help, title, and description can be overridden.
183 super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass); 195 NSMutableArray extraAttributes = NSMutableArray.arrayWithCapacity(3);
184 return OS.objc_msgSendSuper(&super_struct, OS.sel_resignFirstResponder) !is null; 196 extraAttributes.addObject(OS.NSAccessibilityHelpAttribute);
197 extraAttributes.addObject(OS.NSAccessibilityDescriptionAttribute);
198 extraAttributes.addObject(OS.NSAccessibilityTitleAttribute);
199
200 for (int i = extraAttributes.count() - 1; i >= 0; i--) {
201 NSString attribute = new NSString(extraAttributes.objectAtIndex(i).id);
202 if (accessible.internal_accessibilityAttributeValue(attribute, ACC.CHILDID_SELF) is null) {
203 extraAttributes.removeObjectAtIndex(i);
204 }
205 }
206
207 if (extraAttributes.count() > 0) {
208 int superResult = super.accessibilityAttributeNames(id, sel);
209 NSArray baseAttributes = new NSArray(superResult);
210 NSMutableArray mutableAttributes = NSMutableArray.arrayWithCapacity(baseAttributes.count() + 1);
211 mutableAttributes.addObjectsFromArray(baseAttributes);
212
213 for (int i = 0; i < extraAttributes.count(); i++) {
214 id currAttribute = extraAttributes.objectAtIndex(i);
215 if (!mutableAttributes.containsObject(currAttribute)) {
216 mutableAttributes.addObject(currAttribute);
217 }
218 }
219
220 return mutableAttributes.id;
221 }
222 }
223 }
224
225 return super.accessibilityAttributeNames(id, sel);
226 }
227
228 int accessibilityParameterizedAttributeNames(int /*long*/ id, int /*long*/ sel) {
229
230 if (id is view.id || (view instanceof NSControl && ((NSControl)view).cell() !is null && ((NSControl)view).cell().id is id)) {
231 if (accessible !is null) {
232 NSArray returnValue = accessible.internal_accessibilityParameterizedAttributeNames(ACC.CHILDID_SELF);
233 if (returnValue !is null) return returnValue.id;
234 }
235 }
236
237 return super.accessibilityParameterizedAttributeNames(id, sel);
238 }
239
240
241 bool accessibilityIsAttributeSettable(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
242
243 // TODO: Carbon didn't support setting attributes, so for now Cocoa doesn't as well.
244 // NSString attribute = new NSString(arg0);
245 //
246 // if (accessible !is null) {
247 // return accessible.accessibilityIsAttributeSettable(attribute, ACC.CHILDID_SELF);
248 // }
249 //
250 // return super.accessibilityIsAttributeSettable(id, sel, arg0);
251 return false;
252 }
253
254 int accessibilityFocusedUIElement(int /*long*/ id, int /*long*/ sel) {
255 id returnValue = null;
256
257 if (id is view.id || (view instanceof NSControl && ((NSControl)view).cell() !is null && ((NSControl)view).cell().id is id)) {
258 if (accessible !is null) {
259 returnValue = accessible.internal_accessibilityFocusedUIElement(ACC.CHILDID_SELF);
260 }
261 }
262
263 // If we had an accessible and it didn't handle the attribute request, let the
264 // superclass handle it.
265 if (returnValue is null)
266 return super.accessibilityFocusedUIElement(id, sel);
267 else
268 return returnValue.id;
269 }
270
271 int accessibilityHitTest(int /*long*/ id, int /*long*/ sel, NSPoint point) {
272 id returnValue = null;
273
274 if (id is view.id || (view instanceof NSControl && ((NSControl)view).cell() !is null && ((NSControl)view).cell().id is id)) {
275 if (accessible !is null) {
276 returnValue = accessible.internal_accessibilityHitTest(point, ACC.CHILDID_SELF);
277 }
278 }
279
280 // If we had an accessible and it didn't handle the attribute request, let the
281 // superclass handle it.
282 if (returnValue is null)
283 return super.accessibilityHitTest(id, sel, point);
284 else
285 return returnValue.id;
286 }
287
288 int accessibilityAttributeValue(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
289 NSString attribute = new NSString(arg0);
290 int returnValue = 0;
291 id returnObject = null;
292
293 if (accessible !is null) {
294 returnObject = accessible.internal_accessibilityAttributeValue(attribute, ACC.CHILDID_SELF);
295 }
296
297 // If we had an accessible and it didn't handle the attribute request, let the
298 // superclass handle it.
299 if (returnObject is null) {
300 returnValue = super.accessibilityAttributeValue(id, sel, arg0);
301 } else {
302 returnValue = returnObject.id;
303 }
304
305 return returnValue;
306 }
307
308 int accessibilityAttributeValue_forParameter(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0, int /*long*/ arg1) {
309 NSString attribute = new NSString(arg0);
310
311 id returnValue = null;
312
313 if (accessible !is null) {
314 id parameter = new id(arg1);
315 returnValue = accessible.internal_accessibilityAttributeValue_forParameter(attribute, parameter, ACC.CHILDID_SELF);
316 }
317
318 // If we had an accessible and it didn't handle the attribute request, let the
319 // superclass handle it.
320 if (returnValue is null)
321 return super.accessibilityAttributeValue_forParameter(id, sel, arg0, arg1);
322 else
323 return returnValue.id;
185 } 324 }
186 325
187 /** 326 /**
188 * Adds the listener to the collection of listeners who will 327 * Adds the listener to the collection of listeners who will
189 * be notified when the control is moved or resized, by sending 328 * be notified when the control is moved or resized, by sending
616 */ 755 */
617 public Point computeSize (int wHint, int hHint, bool changed) { 756 public Point computeSize (int wHint, int hHint, bool changed) {
618 checkWidget(); 757 checkWidget();
619 int width = DEFAULT_WIDTH; 758 int width = DEFAULT_WIDTH;
620 int height = DEFAULT_HEIGHT; 759 int height = DEFAULT_HEIGHT;
621 // if (wHint !is DWT.DEFAULT) width = wHint;
622 // if (hHint !is DWT.DEFAULT) height = hHint;
623 // int border = getBorderWidth ();
624 // width += border * 2;
625 // height += border * 2;
626 // return new Point (width, height);
627 if (cast(NSControl) topView()) { 760 if (cast(NSControl) topView()) {
628 NSRect oldRect = topView().frame(); 761 NSRect oldRect = topView().frame();
629 (cast(NSControl)topView()).sizeToFit(); 762 (cast(NSControl)topView()).sizeToFit();
630 NSRect newRect = topView().frame(); 763 NSRect newRect = topView().frame();
631 topView().setFrame (oldRect); 764 topView().setFrame (oldRect);
632 return new Point (cast(int)newRect.width, cast(int)newRect.height); 765 width = cast(int) newRect.width;
766 height = cast(int)newRect.height;
767 }
768 int border = getBorderWidth ();
769 if (wHint !is DWT.DEFAULT) {
770 width = wHint;
771 width += border * 2;
772 }
773 if (hHint !is DWT.DEFAULT) {
774 height = hHint;
775 height += border * 2;
633 } 776 }
634 return new Point (width, height); 777 return new Point (width, height);
635 } 778 }
636 779
637 Control computeTabGroup () { 780 Control computeTabGroup () {
661 } 804 }
662 } 805 }
663 return parent.computeTabRoot (); 806 return parent.computeTabRoot ();
664 } 807 }
665 808
809 NSView contentView () {
810 return view;
811 }
812
666 void createWidget () { 813 void createWidget () {
667 state |= DRAG_DETECT; 814 state |= DRAG_DETECT;
668 checkOrientation (parent); 815 checkOrientation (parent);
669 super.createWidget (); 816 super.createWidget ();
670 checkBackground (); 817 checkBackground ();
690 837
691 Color defaultForeground () { 838 Color defaultForeground () {
692 return display.getSystemColor (DWT.COLOR_WIDGET_FOREGROUND); 839 return display.getSystemColor (DWT.COLOR_WIDGET_FOREGROUND);
693 } 840 }
694 841
842 void deregister () {
843 super.deregister ();
844 display.removeWidget (view);
845 }
846
695 void destroyWidget () { 847 void destroyWidget () {
696 NSView view = topView (); 848 NSView view = topView ();
697 view.removeFromSuperview (); 849 view.removeFromSuperview ();
698 releaseHandle (); 850 releaseHandle ();
851 }
852
853 void doCommandBySelector (int /*long*/ id, int /*long*/ sel, int /*long*/ selector) {
854 if (view.window ().firstResponder ().id is id) {
855 NSEvent nsEvent = NSApplication.sharedApplication ().currentEvent ();
856 if (nsEvent !is null && nsEvent.type () is OS.NSKeyDown) {
857 // TODO is this workaround ok?
858 /*
859 * Feature in Cocoa. Pressing Alt+UpArrow invokes doCommandBySelector
860 * twice, with selectors moveBackward and moveToBeginningOfParagraph
861 * (Alt+DownArrow behaves similarly). In order to avoid sending
862 * multiple events for these keys, do not send a KeyDown if the
863 * selector is moveToBeginningOfParagraph or moveToEndOfParagraph.
864 */
865 if (selector is OS.sel_moveToBeginningOfParagraph_|| selector is OS.sel_moveToEndOfParagraph_) return;
866
867 bool [] consume = new bool [1];
868 if (translateTraversal (nsEvent.keyCode (), nsEvent, consume)) return;
869 if (isDisposed ()) return;
870 if (!sendKeyEvent (nsEvent, DWT.KeyDown)) return;
871 if (consume [0]) return;
872 }
873 if ((state & CANVAS) !is 0) return;
874 }
875 super.doCommandBySelector (id, sel, selector);
699 } 876 }
700 877
701 /** 878 /**
702 * Detects a drag and drop gesture. This method is used 879 * Detects a drag and drop gesture. This method is used
703 * to detect a drag gesture when called from within a mouse 880 * to detect a drag gesture when called from within a mouse
735 * @since 3.3 912 * @since 3.3
736 */ 913 */
737 public bool dragDetect (Event event) { 914 public bool dragDetect (Event event) {
738 checkWidget (); 915 checkWidget ();
739 if (event is null) error (DWT.ERROR_NULL_ARGUMENT); 916 if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
740 return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); 917 return dragDetect ();
741 } 918 }
742 919
743 /** 920 /**
744 * Detects a drag and drop gesture. This method is used 921 * Detects a drag and drop gesture. This method is used
745 * to detect a drag gesture when called from within a mouse 922 * to detect a drag gesture when called from within a mouse
777 * @since 3.3 954 * @since 3.3
778 */ 955 */
779 public bool dragDetect (MouseEvent event) { 956 public bool dragDetect (MouseEvent event) {
780 checkWidget (); 957 checkWidget ();
781 if (event is null) error (DWT.ERROR_NULL_ARGUMENT); 958 if (event is null) error (DWT.ERROR_NULL_ARGUMENT);
782 return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); 959 return dragDetect();
783 } 960 }
784 961
785 bool dragDetect (int button, int count, int stateMask, int x, int y) { 962 bool dragDetect () {
786 if (button !is 1 || count !is 1) return false; 963 NSApplication application = NSApplication.sharedApplication();
787 if (!dragDetect (x, y, false, null)) return false; 964 NSEvent event = application.nextEventMatchingMask(OS.NSLeftMouseDraggedMask, NSDate.dateWithTimeIntervalSinceNow(0.2), OS.NSDefaultRunLoopMode, false);
788 return sendDragEvent (button, stateMask, x, y); 965 return (event !is null);
789 } 966 }
790 967
791 bool dragDetect (int x, int y, bool filter, bool [] consume) { 968 bool dragDetect (int x, int y, bool filter, bool [] consume) {
792 // Rect rect = new Rect (); 969 return dragDetect();
793 // int window = OS.GetControlOwner (handle);
794 // CGPoint pt = new CGPoint ();
795 // OS.HIViewConvertPoint (pt, handle, 0);
796 // x += cast(int) pt.x;
797 // y += cast(int) pt.y;
798 // OS.GetWindowBounds (window, cast(short) OS.kWindowStructureRgn, rect);
799 // x += rect.left;
800 // y += rect.top;
801 // dwt.internal.carbon.Point pt1 = new dwt.internal.carbon.Point ();
802 // pt1.h = cast(short) x;
803 // pt1.v = cast(short) y;
804 // return OS.WaitMouseMoved (pt1);
805 return false;
806 } 970 }
807 971
808 bool drawGripper (int x, int y, int width, int height, bool vertical) { 972 bool drawGripper (int x, int y, int width, int height, bool vertical) {
809 return false; 973 return false;
810 } 974 }
811 975
812 void drawRect(objc.id id, NSRect rect) { 976 void drawWidget (objc.id id, NSRect rect) {
813 super.drawRect(id, rect); 977 if (id !is view.id) return;
814 if (!hooks (DWT.Paint) && !filters (DWT.Paint)) return; 978 if (!hooks (DWT.Paint) && !filters (DWT.Paint)) return;
815 979
816 /* Send paint event */ 980 /* Send paint event */
817 GCData data = new GCData (); 981 GCData data = new GCData ();
818 data.paintRectStruct = rect; 982 data.paintRectStruct = rect;
828 event.gc = null; 992 event.gc = null;
829 gc.dispose (); 993 gc.dispose ();
830 } 994 }
831 995
832 void enableWidget (bool enabled) { 996 void enableWidget (bool enabled) {
833 //TODO - other views
834 if (cast(NSControl) view) { 997 if (cast(NSControl) view) {
835 (cast(NSControl)view).setEnabled(enabled); 998 (cast(NSControl)view).setEnabled(enabled);
999 }
1000 }
1001
1002 void fillBackground (NSView view, NSGraphicsContext context, NSRect rect) {
1003 Control control = findBackgroundControl();
1004 if (control is null) control = this;
1005 Image image = control.backgroundImage;
1006 if (image !is null && !image.isDisposed()) {
1007 context.saveGraphicsState();
1008 NSColor.colorWithPatternImage(image.handle).setFill();
1009 NSPoint phase = new NSPoint();
1010 NSView controlView = control.view;
1011 NSView contentView = controlView.window().contentView();
1012 phase = controlView.convertPoint_toView_(phase, contentView);
1013 phase.y = contentView.bounds().height - phase.y;
1014 context.setPatternPhase(phase);
1015 NSBezierPath.fillRect(rect);
1016 context.restoreGraphicsState();
1017 return;
1018 }
1019 Color background = control.getBackgroundColor ();
1020 if (background !is null && !background.isDisposed ()) {
1021 float [] color = background.handle;
1022 context.saveGraphicsState();
1023 NSColor.colorWithDeviceRed(color [0], color [1], color [2], getThemeAlpha()).setFill();
1024 NSBezierPath.fillRect(rect);
1025 context.restoreGraphicsState();
1026 return;
836 } 1027 }
837 } 1028 }
838 1029
839 Cursor findCursor () { 1030 Cursor findCursor () {
840 if (cursor !is null) return cursor; 1031 if (cursor !is null) return cursor;
865 shell.setSavedFocus (focusControl); 1056 shell.setSavedFocus (focusControl);
866 // int window = OS.GetControlOwner (handle); 1057 // int window = OS.GetControlOwner (handle);
867 // OS.ClearKeyboardFocus (window); 1058 // OS.ClearKeyboardFocus (window);
868 } 1059 }
869 1060
1061 void flagsChanged (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1062 if (view.window ().firstResponder ().id is id) {
1063 if ((state & SAFARI_EVENTS_FIX) is 0) {
1064 int mask = 0;
1065 NSEvent nsEvent = new NSEvent (theEvent);
1066 int /*long*/ modifiers = nsEvent.modifierFlags ();
1067 int keyCode = Display.translateKey (nsEvent.keyCode ());
1068 switch (keyCode) {
1069 case DWT.ALT: mask = OS.NSAlternateKeyMask; break;
1070 case DWT.CONTROL: mask = OS.NSControlKeyMask; break;
1071 case DWT.COMMAND: mask = OS.NSCommandKeyMask; break;
1072 case DWT.SHIFT: mask = OS.NSShiftKeyMask; break;
1073 case DWT.CAPS_LOCK:
1074 Event event = new Event();
1075 event.keyCode = keyCode;
1076 setInputState (event, nsEvent, DWT.KeyDown);
1077 sendKeyEvent (DWT.KeyDown, event);
1078 setInputState (event, nsEvent, DWT.KeyUp);
1079 sendKeyEvent (DWT.KeyUp, event);
1080 break;
1081 }
1082 if (mask !is 0) {
1083 int type = (mask & modifiers) !is 0 ? DWT.KeyDown : DWT.KeyUp;
1084 Event event = new Event();
1085 event.keyCode = keyCode;
1086 setInputState (event, nsEvent, type);
1087 if (!sendKeyEvent (type, event)) return;
1088 }
1089 }
1090 }
1091 super.flagsChanged (id, sel, theEvent);
1092 }
1093
1094 NSView focusView () {
1095 return view;
1096 }
1097
870 /** 1098 /**
871 * Forces the receiver to have the <em>keyboard focus</em>, causing 1099 * Forces the receiver to have the <em>keyboard focus</em>, causing
872 * all keyboard events to be delivered to it. 1100 * all keyboard events to be delivered to it.
873 * 1101 *
874 * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to. 1102 * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
880 * 1108 *
881 * @see #setFocus 1109 * @see #setFocus
882 */ 1110 */
883 public bool forceFocus () { 1111 public bool forceFocus () {
884 checkWidget(); 1112 checkWidget();
885 // if (display.focusEvent is DWT.FocusOut) return false;
886 Decorations shell = menuShell (); 1113 Decorations shell = menuShell ();
887 shell.setSavedFocus (this); 1114 shell.setSavedFocus (this);
888 if (!isEnabled () || !isVisible ()/* || !isActive ()*/) return false; 1115 if (!isEnabled () || !isVisible ()/* || !isActive ()*/) return false;
889 if (isFocusControl ()) return true; 1116 if (isFocusControl ()) return true;
890 shell.setSavedFocus (null); 1117 shell.setSavedFocus (null);
891 shell.bringToTop (false); 1118 shell.bringToTop (false);
892 if (isDisposed ()) return false; 1119 if (isDisposed ()) return false;
893 view.window ().makeFirstResponder (view); 1120 bool result = view.window ().makeFirstResponder (focusView ());
894 if (isDisposed ()) return false; 1121 if (isDisposed ()) return false;
895 shell.setSavedFocus (this); 1122 shell.setSavedFocus (this);
896 return hasFocus (); 1123 return result;
897 } 1124 }
898 1125
899 /** 1126 /**
900 * Returns the accessible object for the receiver. 1127 * Returns the accessible object for the receiver.
901 * If this is the first time this object is requested, 1128 * If this is the first time this object is requested,
916 public Accessible getAccessible () { 1143 public Accessible getAccessible () {
917 checkWidget (); 1144 checkWidget ();
918 if (accessible is null) accessible = new_Accessible (this); 1145 if (accessible is null) accessible = new_Accessible (this);
919 return accessible; 1146 return accessible;
920 } 1147 }
921 1148
922 /** 1149 /**
923 * Returns the receiver's background color. 1150 * Returns the receiver's background color.
924 * 1151 *
925 * @return the background color 1152 * @return the background color
926 * 1153 *
1007 * @since 3.3 1234 * @since 3.3
1008 */ 1235 */
1009 public bool getDragDetect () { 1236 public bool getDragDetect () {
1010 checkWidget (); 1237 checkWidget ();
1011 return (state & DRAG_DETECT) !is 0; 1238 return (state & DRAG_DETECT) !is 0;
1239 }
1240
1241 NSBezierPath getClipping() {
1242 return parent.getClipping ();
1012 } 1243 }
1013 1244
1014 /** 1245 /**
1015 * Returns the receiver's cursor, or null if it has not been set. 1246 * Returns the receiver's cursor, or null if it has not been set.
1016 * <p> 1247 * <p>
1017 * When the mouse pointer passes over a control its appearance 1248 * When the mouse pointer passes over a control its appearance
1018 * is changed to match the control's cursor. 1249 * is changed to match the control's cursor.
1019 * </p> 1250 * </p>
1020 * </ul> 1251 *
1252 * @return the receiver's cursor or <code>null</code>
1253 *
1021 * @exception DWTException <ul> 1254 * @exception DWTException <ul>
1022 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 1255 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1023 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1256 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1024 * </ul> 1257 * </ul>
1025 * 1258 *
1213 control = control.parent; 1446 control = control.parent;
1214 } 1447 }
1215 return result; 1448 return result;
1216 } 1449 }
1217 1450
1451 /**
1452 * Returns the region that defines the shape of the control,
1453 * or null if the control has the default shape.
1454 *
1455 * @return the region that defines the shape of the shell (or null)
1456 *
1457 * @exception DWTException <ul>
1458 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1459 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1460 * </ul>
1461 *
1462 * @since 3.4
1463 */
1218 public Region getRegion () { 1464 public Region getRegion () {
1219 checkWidget (); 1465 checkWidget ();
1220 return region; 1466 return region;
1221 } 1467 }
1222 1468
1255 */ 1501 */
1256 public Point getSize () { 1502 public Point getSize () {
1257 checkWidget(); 1503 checkWidget();
1258 NSRect rect = topView().frame(); 1504 NSRect rect = topView().frame();
1259 return new Point(cast(int)rect.width, cast(int)rect.height); 1505 return new Point(cast(int)rect.width, cast(int)rect.height);
1506 }
1507
1508 float getThemeAlpha () {
1509 return 1 * parent.getThemeAlpha ();
1260 } 1510 }
1261 1511
1262 /** 1512 /**
1263 * Returns the receiver's tool tip text, or null if it has 1513 * Returns the receiver's tool tip text, or null if it has
1264 * not been set. 1514 * not been set.
1300 bool hasBorder () { 1550 bool hasBorder () {
1301 return (style & DWT.BORDER) !is 0; 1551 return (style & DWT.BORDER) !is 0;
1302 } 1552 }
1303 1553
1304 bool hasFocus () { 1554 bool hasFocus () {
1305 return this is display.getFocusControl (); 1555 return (view.window().firstResponder().id is view.id);
1556 }
1557
1558 int /*long*/ hitTest (int /*long*/ id, int /*long*/ sel, NSPoint point) {
1559 if ((state & DISABLED) !is 0) return 0;
1560 return super.hitTest(id, sel, point);
1561 }
1562
1563 bool insertText (int /*long*/ id, int /*long*/ sel, int /*long*/ string) {
1564 if (view.window ().firstResponder ().id is id) {
1565 NSEvent nsEvent = NSApplication.sharedApplication ().currentEvent ();
1566 if (nsEvent !is null && nsEvent.type () is OS.NSKeyDown) {
1567 NSString str = new NSString (string);
1568 if (str.isKindOfClass (OS.objc_getClass ("NSAttributedString"))) {
1569 str = new NSAttributedString (string).string ();
1570 }
1571 int length = (int)/*64*/str.length ();
1572 char[] buffer = new char [length];
1573 str.getCharacters(buffer);
1574 for (int i = 0; i < buffer.length; i++) {
1575 Event event = new Event ();
1576 if (length is 1) setKeyState (event, DWT.KeyDown, nsEvent);
1577 event.character = buffer [i];
1578 if (!sendKeyEvent (nsEvent, DWT.KeyDown)) return false;
1579 }
1580 }
1581 if ((state & CANVAS) !is 0) return true;
1582 }
1583 return super.insertText (id, sel, string);
1306 } 1584 }
1307 1585
1308 /** 1586 /**
1309 * Invokes platform specific functionality to allocate a new GC handle. 1587 * Invokes platform specific functionality to allocate a new GC handle.
1310 * <p> 1588 * <p>
1322 checkWidget(); 1600 checkWidget();
1323 objc.id context = null; 1601 objc.id context = null;
1324 if (data !is null && data.paintRect !is null) { 1602 if (data !is null && data.paintRect !is null) {
1325 context = NSGraphicsContext.currentContext().id_; 1603 context = NSGraphicsContext.currentContext().id_;
1326 } else { 1604 } else {
1327 context = NSGraphicsContext.graphicsContextWithWindow(view.window()).id_; 1605 NSGraphicsContext graphicsContext = NSGraphicsContext.graphicsContextWithWindow (view.window ());
1606 display.addContext (graphicsContext);
1607 context = graphicsContext.id_;
1328 } 1608 }
1329 if (data !is null) { 1609 if (data !is null) {
1330 int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; 1610 int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
1331 if ((data.style & mask) is 0) { 1611 if ((data.style & mask) is 0) {
1332 data.style |= style & (mask | DWT.MIRRORED); 1612 data.style |= style & (mask | DWT.MIRRORED);
1333 } 1613 }
1334 data.device = display; 1614 data.device = display;
1615 data.thread = display.thread;
1335 data.view = view; 1616 data.view = view;
1336 data.foreground = getForegroundColor ().handle; 1617 data.foreground = getForegroundColor ().handle;
1337 Control control = findBackgroundControl (); 1618 Control control = findBackgroundControl ();
1338 if (control is null) control = this; 1619 if (control is null) control = this;
1339 data.background = control.getBackgroundColor ().handle; 1620 data.background = control.getBackgroundColor ().handle;
1340 data.font = font !is null ? font : defaultFont (); 1621 data.font = font !is null ? font : defaultFont ();
1341 } 1622 }
1342 return context; 1623 return context;
1343 } 1624 }
1344 1625
1345 /** 1626 /**
1354 * 1635 *
1355 * @param hDC the platform specific GC handle 1636 * @param hDC the platform specific GC handle
1356 * @param data the platform specific GC data 1637 * @param data the platform specific GC data
1357 */ 1638 */
1358 public void internal_dispose_GC (objc.id context, GCData data) { 1639 public void internal_dispose_GC (objc.id context, GCData data) {
1359 checkWidget (); 1640 checkWidget ();
1641 NSGraphicsContext graphicsContext = new NSGraphicsContext (context);
1642 display.removeContext (graphicsContext);
1643 if (data !is null) {
1644 if (data.paintRect !is null) {
1645 NSGraphicsContext.setCurrentContext (graphicsContext);
1646 } else {
1647 graphicsContext.flushGraphics ();
1648 }
1649 }
1360 } 1650 }
1361 1651
1362 /** 1652 /**
1363 * Returns <code>true</code> if the receiver is enabled and all 1653 * Returns <code>true</code> if the receiver is enabled and all
1364 * ancestors up to and including the receiver's nearest ancestor 1654 * ancestors up to and including the receiver's nearest ancestor
1402 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1692 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1403 * </ul> 1693 * </ul>
1404 */ 1694 */
1405 public bool isFocusControl () { 1695 public bool isFocusControl () {
1406 checkWidget(); 1696 checkWidget();
1407 // Control focusControl = display.focusControl;
1408 // if (focusControl !is null && !focusControl.isDisposed ()) {
1409 // return this is focusControl;
1410 // }
1411 return hasFocus (); 1697 return hasFocus ();
1412 } 1698 }
1413 1699
1414 /** 1700 /**
1415 * Returns <code>true</code> if the underlying operating 1701 * Returns <code>true</code> if the underlying operating
1465 } 1751 }
1466 int code = traversalCode (0, null); 1752 int code = traversalCode (0, null);
1467 return (code & (DWT.TRAVERSE_ARROW_PREVIOUS | DWT.TRAVERSE_ARROW_NEXT)) !is 0; 1753 return (code & (DWT.TRAVERSE_ARROW_PREVIOUS | DWT.TRAVERSE_ARROW_NEXT)) !is 0;
1468 } 1754 }
1469 1755
1756 bool isTrim (NSView view) {
1757 return false;
1758 }
1759
1470 /** 1760 /**
1471 * Returns <code>true</code> if the receiver is visible and all 1761 * Returns <code>true</code> if the receiver is visible and all
1472 * ancestors up to and including the receiver's nearest ancestor 1762 * ancestors up to and including the receiver's nearest ancestor
1473 * shell are visible. Otherwise, <code>false</code> is returned. 1763 * shell are visible. Otherwise, <code>false</code> is returned.
1474 * 1764 *
1484 public bool isVisible () { 1774 public bool isVisible () {
1485 checkWidget(); 1775 checkWidget();
1486 return getVisible () && parent.isVisible (); 1776 return getVisible () && parent.isVisible ();
1487 } 1777 }
1488 1778
1489 objc.id menuForEvent (objc.id nsEvent) { 1779 void keyDown (objc.id id, objc.SEL sel, objc.id theEvent) {
1490 NSPoint pt = NSEvent.mouseLocation(); 1780 if (view.window ().firstResponder ().id_ is id) {
1491 NSWindow window = view.window(); 1781 bool textInput = OS.objc_msgSend (id, OS.sel_conformsToProtocol_, OS.objc_getProtocol ("NSTextInput")) !is null;
1492 pt.y = cast(int) (window.screen().frame().height - pt.y); 1782 if (!textInput) {
1783 NSEvent nsEvent = new NSEvent (theEvent);
1784 bool [] consume = new bool [1];
1785 if (translateTraversal (nsEvent.keyCode (), nsEvent, consume)) return;
1786 if (isDisposed ()) return;
1787 if (!sendKeyEvent (nsEvent, DWT.KeyDown)) return;
1788 if (consume [0]) return;
1789 }
1790 }
1791 super.keyDown (id, sel, theEvent);
1792 }
1793
1794 void keyUp (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1795 if (view.window ().firstResponder ().id is id) {
1796 NSEvent nsEvent = new NSEvent (theEvent);
1797 if (!sendKeyEvent (nsEvent, DWT.KeyUp)) return;
1798 }
1799 super.keyUp (id, sel, theEvent);
1800 }
1801
1802 void markLayout (bool changed, bool all) {
1803 /* Do nothing */
1804 }
1805
1806 int /*long*/ menuForEvent (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1807 NSPoint pt = NSEvent.mouseLocation();
1808 pt.y = (int) (display.getPrimaryFrame().height - pt.y);
1493 int x = cast(int) pt.x; 1809 int x = cast(int) pt.x;
1494 int y = cast(int) pt.y; 1810 int y = cast(int) pt.y;
1495 Event event = new Event (); 1811 Event event = new Event ();
1496 event.x = x; 1812 event.x = x;
1497 event.y = y; 1813 event.y = y;
1502 if (x !is event.x || y !is event.y) { 1818 if (x !is event.x || y !is event.y) {
1503 menu.setLocation (event.x, event.y); 1819 menu.setLocation (event.x, event.y);
1504 } 1820 }
1505 return menu.nsMenu.id_; 1821 return menu.nsMenu.id_;
1506 } 1822 }
1507 objc_super super_struct = objc_super(); 1823 return super.menuForEvent (id, sel, theEvent);
1508 super_struct.receiver = view.id_;
1509 super_struct.cls = cast(objc.Class) OS.objc_msgSend(view.id_, OS.sel_superclass);
1510 return OS.objc_msgSendSuper(&super_struct, OS.sel_menuForEvent_1, nsEvent);
1511 } 1824 }
1512 1825
1513 Decorations menuShell () { 1826 Decorations menuShell () {
1514 return parent.menuShell (); 1827 return parent.menuShell ();
1515 } 1828 }
1516 1829
1517 bool setInputState (Event event, NSEvent nsEvent, int type) { 1830 void scrollWheel (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1518 int modifierFlags = nsEvent.modifierFlags(); 1831 if (id is view.id) {
1519 if ((modifierFlags & OS.NSAlternateKeyMask) !is 0) event.stateMask |= DWT.ALT; 1832 if (hooks (DWT.MouseWheel) || filters (DWT.MouseWheel)) {
1520 if ((modifierFlags & OS.NSShiftKeyMask) !is 0) event.stateMask |= DWT.SHIFT; 1833 NSEvent nsEvent = new NSEvent(theEvent);
1521 if ((modifierFlags & OS.NSControlKeyMask) !is 0) event.stateMask |= DWT.CONTROL; 1834 if (nsEvent.deltaY() !is 0) {
1522 if ((modifierFlags & OS.NSCommandKeyMask) !is 0) event.stateMask |= DWT.COMMAND; 1835 if (!sendMouseEvent(nsEvent, DWT.MouseWheel, true)) {
1523 1836 return;
1524 //WRONG 1837 }
1525 if ((modifierFlags & OS.NSLeftMouseDownMask) !is 0) event.stateMask |= DWT.BUTTON1; 1838 }
1526 if ((modifierFlags & OS.NSLeftMouseDraggedMask) !is 0) event.stateMask |= DWT.BUTTON1;
1527 if ((modifierFlags & OS.NSLeftMouseUpMask) !is 0) event.stateMask |= DWT.BUTTON1;
1528 if ((modifierFlags & OS.NSOtherMouseDownMask) !is 0) event.stateMask |= DWT.BUTTON2;
1529 if ((modifierFlags & OS.NSOtherMouseDraggedMask) !is 0) event.stateMask |= DWT.BUTTON2;
1530 if ((modifierFlags & OS.NSOtherMouseUpMask) !is 0) event.stateMask |= DWT.BUTTON1;
1531 if ((modifierFlags & OS.NSRightMouseDownMask) !is 0) event.stateMask |= DWT.BUTTON3;
1532 if ((modifierFlags & OS.NSRightMouseDraggedMask) !is 0) event.stateMask |= DWT.BUTTON3;
1533 if ((modifierFlags & OS.NSRightMouseUpMask) !is 0) event.stateMask |= DWT.BUTTON3;
1534
1535 // if (OS.GetKeyState (OS.VK_XBUTTON1) < 0) event.stateMask |= DWT.BUTTON4;
1536 // if (OS.GetKeyState (OS.VK_XBUTTON2) < 0) event.stateMask |= DWT.BUTTON5;
1537 // switch (type) {
1538 // case DWT.MouseDown:
1539 // case DWT.MouseDoubleClick:
1540 // if (event.button is 1) event.stateMask &= ~DWT.BUTTON1;
1541 // if (event.button is 2) event.stateMask &= ~DWT.BUTTON2;
1542 // if (event.button is 3) event.stateMask &= ~DWT.BUTTON3;
1543 // if (event.button is 4) event.stateMask &= ~DWT.BUTTON4;
1544 // if (event.button is 5) event.stateMask &= ~DWT.BUTTON5;
1545 // break;
1546 // case DWT.MouseUp:
1547 // if (event.button is 1) event.stateMask |= DWT.BUTTON1;
1548 // if (event.button is 2) event.stateMask |= DWT.BUTTON2;
1549 // if (event.button is 3) event.stateMask |= DWT.BUTTON3;
1550 // if (event.button is 4) event.stateMask |= DWT.BUTTON4;
1551 // if (event.button is 5) event.stateMask |= DWT.BUTTON5;
1552 // break;
1553 // case DWT.KeyDown:
1554 // case DWT.Traverse:
1555 // if (event.keyCode is DWT.ALT) event.stateMask &= ~DWT.ALT;
1556 // if (event.keyCode is DWT.SHIFT) event.stateMask &= ~DWT.SHIFT;
1557 // if (event.keyCode is DWT.CONTROL) event.stateMask &= ~DWT.CONTROL;
1558 // break;
1559 // case DWT.KeyUp:
1560 // if (event.keyCode is DWT.ALT) event.stateMask |= DWT.ALT;
1561 // if (event.keyCode is DWT.SHIFT) event.stateMask |= DWT.SHIFT;
1562 // if (event.keyCode is DWT.CONTROL) event.stateMask |= DWT.CONTROL;
1563 // break;
1564 // }
1565 return true;
1566 }
1567
1568 void sendMouseEvent (NSEvent nsEvent, int type, int button) {
1569 Event event = new Event ();
1570 event.button = button;
1571 // event.detail = detail;
1572 event.count = nsEvent.clickCount();
1573 NSPoint location = nsEvent.locationInWindow();
1574 NSPoint point = view.convertPoint_fromView_(location, null);
1575 event.x = cast(int) point.x;
1576 event.y = cast(int) point.y;
1577 setInputState (event, nsEvent, type);
1578 sendEvent (type, event);
1579 }
1580
1581 void mouseDown(objc.id theEvent) {
1582 NSEvent nsEvent = new NSEvent (theEvent);
1583 sendMouseEvent (nsEvent, DWT.MouseDown, 1);
1584 }
1585
1586 void mouseDragged(objc.id theEvent) {
1587 NSEvent nsEvent = new NSEvent (theEvent);
1588 sendMouseEvent (nsEvent, DWT.MouseMove, 1);
1589 }
1590
1591 void mouseUp(objc.id theEvent) {
1592 NSEvent nsEvent = new NSEvent (theEvent);
1593 sendMouseEvent (nsEvent, DWT.MouseUp, 1);
1594 }
1595
1596 bool sendKeyEvent (Event event) {
1597 sendEvent (event);
1598 return event.doit;
1599 }
1600
1601 //TODO - missing modifier keys (see flagsChanged:)
1602 bool sendKeyEvent (NSEvent nsEvent, int type) {
1603 if ((state & SAFARI_EVENTS_FIX) !is 0) return false;
1604 int count = 0;
1605 NSString keys = nsEvent.characters();
1606 //TODO - check lowercase doesn't mangle char codes
1607 NSString keyCodes = nsEvent.charactersIgnoringModifiers().lowercaseString();
1608 char [] chars = new char [keys.length()];
1609 for (int i=0; i<keys.length(); i++) {
1610 Event event = new Event ();
1611 int keyCode = Display.translateKey (keys.characterAtIndex (i) & 0xFFFF);
1612 if (keyCode !is 0) {
1613 event.keyCode = keyCode;
1614 } else {
1615 event.character = cast(char) keys.characterAtIndex (i);
1616 //TODO - get unshifted values for Shift+1
1617 event.keyCode = keyCodes.characterAtIndex (i);
1618 } 1839 }
1619 setInputState (event, nsEvent, type); 1840 }
1620 if (!setKeyState(event, type, nsEvent)) return false; 1841 super.scrollWheel(id, sel, theEvent);
1621 if ((cast(Widget)this).sendKeyEvent (type, event)) { 1842 }
1622 chars [count++] = chars [i]; 1843
1623 } 1844 void mouseDown(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
1624 } 1845 Display display = this.display;
1625 // if (count is 0) return false; 1846 display.trackingControl = this;
1626 if (count !is keys.length () - 1) { 1847 super.mouseDown(id, sel, theEvent);
1627 // OS.SetEventParameter (theEvent, OS.kEventParamKeyUnicodes, OS.typeUnicodeText, count * 2, chars); 1848 display.trackingControl = null;
1628 } 1849 }
1629 return count is keys.length (); 1850
1630 } 1851 void moved () {
1631 1852 sendEvent (DWT.Move);
1632 void markLayout (bool changed, bool all) {
1633 /* Do nothing */
1634 } 1853 }
1635 1854
1636 /** 1855 /**
1637 * Moves the receiver above the specified control in the 1856 * Moves the receiver above the specified control in the
1638 * drawing order. If the argument is null, then the receiver 1857 * drawing order. If the argument is null, then the receiver
1736 public void pack (bool changed) { 1955 public void pack (bool changed) {
1737 checkWidget(); 1956 checkWidget();
1738 setSize (computeSize (DWT.DEFAULT, DWT.DEFAULT, changed)); 1957 setSize (computeSize (DWT.DEFAULT, DWT.DEFAULT, changed));
1739 } 1958 }
1740 1959
1960 /**
1961 * Prints the receiver and all children.
1962 *
1963 * @param gc the gc where the drawing occurs
1964 * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
1965 *
1966 * @exception IllegalArgumentException <ul>
1967 * <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
1968 * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
1969 * </ul>
1970 * @exception DWTException <ul>
1971 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1972 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1973 * </ul>
1974 *
1975 * @since 3.4
1976 */
1741 public bool print (GC gc) { 1977 public bool print (GC gc) {
1742 checkWidget (); 1978 checkWidget ();
1743 if (gc is null) error (DWT.ERROR_NULL_ARGUMENT); 1979 if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
1744 if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); 1980 if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
1745 // int [] outImage = new int [1]; 1981 // int [] outImage = new int [1];
1825 rect.width = width; 2061 rect.width = width;
1826 rect.height = height; 2062 rect.height = height;
1827 view.setNeedsDisplayInRect(rect); 2063 view.setNeedsDisplayInRect(rect);
1828 } 2064 }
1829 2065
2066 void register () {
2067 super.register ();
2068 display.addWidget (view, this);
2069 }
2070
1830 void releaseHandle () { 2071 void releaseHandle () {
1831 super.releaseHandle (); 2072 super.releaseHandle ();
1832 if (view !is null) { 2073 if (view !is null) view.release();
1833 OS.objc_msgSend(view.id_, OS.sel_setTag_1, -1);
1834 view.release();
1835 }
1836 view = null; 2074 view = null;
1837 parent = null; 2075 parent = null;
1838 } 2076 }
1839 2077
1840 void releaseParent () { 2078 void releaseParent () {
1841 // setVisible (topHandle (), false);
1842 parent.removeControl (this); 2079 parent.removeControl (this);
1843 } 2080 }
1844 2081
1845 void releaseWidget () { 2082 void releaseWidget () {
1846 super.releaseWidget (); 2083 super.releaseWidget ();
2084 if (display.currentControl is this) {
2085 display.currentControl = null;
2086 display.timerExec(-1, display.hoverTimer);
2087 }
2088 if (display.grabControl is this) {
2089 display.grabControl = null;
2090 }
1847 if (menu !is null && !menu.isDisposed ()) { 2091 if (menu !is null && !menu.isDisposed ()) {
1848 menu.dispose (); 2092 menu.dispose ();
1849 } 2093 }
1850 menu = null; 2094 menu = null;
1851 layoutData = null; 2095 layoutData = null;
2154 public void removeTraverseListener(TraverseListener listener) { 2398 public void removeTraverseListener(TraverseListener listener) {
2155 checkWidget(); 2399 checkWidget();
2156 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); 2400 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
2157 if (eventTable is null) return; 2401 if (eventTable is null) return;
2158 eventTable.unhook (DWT.Traverse, listener); 2402 eventTable.unhook (DWT.Traverse, listener);
2403 }
2404
2405 void resized () {
2406 sendEvent (DWT.Resize);
2159 } 2407 }
2160 2408
2161 bool sendDragEvent (int button, int stateMask, int x, int y) { 2409 bool sendDragEvent (int button, int stateMask, int x, int y) {
2162 Event event = new Event (); 2410 Event event = new Event ();
2163 event.button = button; 2411 event.button = button;
2166 event.stateMask = stateMask; 2414 event.stateMask = stateMask;
2167 postEvent (DWT.DragDetect, event); 2415 postEvent (DWT.DragDetect, event);
2168 return event.doit; 2416 return event.doit;
2169 } 2417 }
2170 2418
2171 bool sendDragEvent (int button, int chord, int modifiers, int x, int y) { 2419 bool sendDragEvent (NSEvent nsEvent) {
2172 Event event = new Event (); 2420 return sendMouseEvent(nsEvent, DWT.DragDetect, true);
2173 switch (button) {
2174 case 1: event.button = 1; break;
2175 case 2: event.button = 3; break;
2176 case 3: event.button = 2; break;
2177 case 4: event.button = 4; break;
2178 case 5: event.button = 5; break;
2179 }
2180 event.x = x;
2181 event.y = y;
2182 setInputState (event, DWT.DragDetect, chord, modifiers);
2183 postEvent (DWT.DragDetect, event);
2184 return event.doit;
2185 } 2421 }
2186 2422
2187 void sendFocusEvent (int type, bool post) { 2423 void sendFocusEvent (int type, bool post) {
2188 Display display = this.display; 2424 Display display = this.display;
2189 Shell shell = getShell (); 2425 Shell shell = getShell ();
2190 /*
2191 * Feature in the Macintosh. GetKeyboardFocus() returns NULL during
2192 * kEventControlSetFocusPart if the focus part is not kControlFocusNoPart.
2193 * The fix is to remember the focus control and return it during
2194 * kEventControlSetFocusPart.
2195 */
2196 // display.focusControl = this;
2197 // display.focusEvent = type;
2198 if (post) { 2426 if (post) {
2199 postEvent (type); 2427 postEvent (type);
2200 } else { 2428 } else {
2201 sendEvent (type); 2429 sendEvent (type);
2202 } 2430 }
2203 /* 2431 /*
2204 * It is possible that the shell may be 2432 * It is possible that the shell may be
2205 * disposed at this point. If this happens 2433 * disposed at this point. If this happens
2206 * don't send the activate and deactivate 2434 * don't send the activate and deactivate
2207 * events. 2435 * events.
2216 shell.setActiveControl (null); 2444 shell.setActiveControl (null);
2217 } 2445 }
2218 break; 2446 break;
2219 } 2447 }
2220 } 2448 }
2221 // display.focusEvent = DWT.None; 2449 }
2222 // display.focusControl = null; 2450
2223 } 2451 bool sendMouseEvent (NSEvent nsEvent, int type, bool send) {
2224 2452 NSInputManager manager = NSInputManager.currentInputManager ();
2225 bool sendMouseEvent (int type, short button, int count, int detail, bool send, int theEvent) { 2453 if (manager !is null && manager.wantsToHandleMouseEvents ()) {
2226 // CGPoint pt = new CGPoint (); 2454 if (manager.handleMouseEvent (nsEvent)) {
2227 // OS.GetEventParameter (theEvent, OS.kEventParamWindowMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt); 2455 return true;
2228 // OS.HIViewConvertPoint (pt, 0, handle); 2456 }
2229 // int x = cast(int) pt.x; 2457 }
2230 // int y = cast(int) pt.y; 2458 Shell shell = null;
2231 // display.lastX = x;
2232 // display.lastY = y;
2233 // int [] chord = new int [1];
2234 // OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
2235 // int [] modifiers = new int [1];
2236 // OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
2237 // return sendMouseEvent (type, button, count, detail, send, chord [0], cast(short) x, cast(short) y, modifiers [0]);
2238 return false;
2239 }
2240
2241 bool sendMouseEvent (int type, short button, int count, bool send, int chord, short x, short y, int modifiers) {
2242 return sendMouseEvent (type, button, count, 0, send, chord, x, y, modifiers);
2243 }
2244
2245 bool sendMouseEvent (int type, short button, int count, int detail, bool send, int chord, short x, short y, int modifiers) {
2246 if (!hooks (type) && !filters (type)) return true;
2247 Event event = new Event (); 2459 Event event = new Event ();
2248 switch (button) { 2460 switch (type) {
2249 case 1: event.button = 1; break; 2461 case DWT.MouseDown:
2250 case 2: event.button = 3; break; 2462 shell = getShell ();
2251 case 3: event.button = 2; break; 2463 //FALL THROUGH
2252 case 4: event.button = 4; break; 2464 case DWT.MouseUp:
2253 case 5: event.button = 5; break; 2465 case DWT.MouseDoubleClick:
2254 } 2466 int button = (int)/*64*/nsEvent.buttonNumber();
2255 event.x = x; 2467 switch (button) {
2256 event.y = y; 2468 case 0: event.button = 1; break;
2257 event.count = count; 2469 case 1: event.button = 3; break;
2258 event.detail = detail; 2470 case 2: event.button = 2; break;
2259 setInputState (event, type, chord, modifiers); 2471 case 3: event.button = 4; break;
2472 case 4: event.button = 5; break;
2473 }
2474 break;
2475 case DWT.MouseWheel:
2476 event.detail = DWT.SCROLL_LINE;
2477 float /*double*/ delta = nsEvent.deltaY();
2478 event.count = delta > 0 ? Math.max (1, (int)delta) : Math.min (-1, (int)delta);
2479 break;
2480 }
2481 if (event.button !is 0) event.count = (int)/*64*/nsEvent.clickCount();
2482 NSPoint windowPoint;
2483 if (nsEvent is null || nsEvent.type() is OS.NSMouseMoved) {
2484 windowPoint = view.window().convertScreenToBase(NSEvent.mouseLocation());
2485 } else {
2486 windowPoint = nsEvent.locationInWindow();
2487 }
2488 NSPoint point = view.convertPoint_fromView_(windowPoint, null);
2489 event.x = (int) point.x;
2490 event.y = (int) point.y;
2491 setInputState (event, nsEvent, type);
2260 if (send) { 2492 if (send) {
2261 sendEvent (type, event); 2493 sendEvent (type, event);
2262 if (isDisposed ()) return false; 2494 if (isDisposed ()) return false;
2263 } else { 2495 } else {
2264 postEvent (type, event); 2496 postEvent (type, event);
2265 } 2497 }
2498 if (shell !is null) shell.setActiveControl(this);
2266 return event.doit; 2499 return event.doit;
2267 }
2268
2269 bool sendMouseWheel (short wheelAxis, int wheelDelta) {
2270 return false;
2271 } 2500 }
2272 2501
2273 void setBackground () { 2502 void setBackground () {
2274 // redrawWidget (handle, false); 2503 // redrawWidget (handle, false);
2275 } 2504 }
2376 public void setBounds (int x, int y, int width, int height) { 2605 public void setBounds (int x, int y, int width, int height) {
2377 checkWidget(); 2606 checkWidget();
2378 setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true); 2607 setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true);
2379 } 2608 }
2380 2609
2381 int setBounds (int x, int y, int width, int height, bool move, bool resize) { 2610 void setBounds (int x, int y, int width, int height, bool move, bool resize) {
2382 int result = 0;
2383 NSView topView = topView(); 2611 NSView topView = topView();
2384 NSRect rect = topView.frame();
2385 if (move && resize) { 2612 if (move && resize) {
2386 if (rect.x !is x || rect.y !is y) result |= MOVED; 2613 NSRect rect = new NSRect();
2387 if (rect.width !is width || rect.height !is height) result |= RESIZED; 2614 rect.x = x;
2388 if (result !is 0) { 2615 rect.y = y;
2389 rect.x = x; 2616 rect.width = width;
2390 rect.y = y; 2617 rect.height = height;
2391 rect.width = width; 2618 topView.setFrame (rect);
2392 rect.height = height;
2393 topView.setFrame (rect);
2394 }
2395 } else if (move) { 2619 } else if (move) {
2396 if (rect.x !is x || rect.y !is y) {
2397 result |= MOVED;
2398 NSPoint point = NSPoint(); 2620 NSPoint point = NSPoint();
2399 point.x = x; 2621 point.x = x;
2400 point.y = y; 2622 point.y = y;
2401 topView.setFrameOrigin(point); 2623 topView.setFrameOrigin(point);
2402 }
2403 } else if (resize) { 2624 } else if (resize) {
2404 if (rect.width !is width || rect.height !is height) {
2405 result |= RESIZED;
2406 NSSize size = NSSize(); 2625 NSSize size = NSSize();
2407 size.width = width; 2626 size.width = width;
2408 size.height = height; 2627 size.height = height;
2409 topView.setFrameSize(size); 2628 topView.setFrameSize(size);
2410 } 2629 }
2411 }
2412 if ((result & MOVED) !is 0) {
2413 sendEvent(DWT.Move);
2414 }
2415 if ((result & RESIZED) !is 0) {
2416 sendEvent(DWT.Resize);
2417 }
2418 return result;
2419 } 2630 }
2420 2631
2421 /** 2632 /**
2422 * Sets the receiver's size and location to the rectangular 2633 * Sets the receiver's size and location to the rectangular
2423 * area specified by the argument. The <code>x</code> and 2634 * area specified by the argument. The <code>x</code> and
2443 } 2654 }
2444 2655
2445 /** 2656 /**
2446 * If the argument is <code>true</code>, causes the receiver to have 2657 * If the argument is <code>true</code>, causes the receiver to have
2447 * all mouse events delivered to it until the method is called with 2658 * all mouse events delivered to it until the method is called with
2448 * <code>false</code> as the argument. 2659 * <code>false</code> as the argument. Note that on some platforms,
2660 * a mouse button must currently be down for capture to be assigned.
2449 * 2661 *
2450 * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it 2662 * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
2451 * 2663 *
2452 * @exception DWTException <ul> 2664 * @exception DWTException <ul>
2453 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 2665 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
2479 */ 2691 */
2480 public void setCursor (Cursor cursor) { 2692 public void setCursor (Cursor cursor) {
2481 checkWidget(); 2693 checkWidget();
2482 if (cursor !is null && cursor.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); 2694 if (cursor !is null && cursor.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
2483 this.cursor = cursor; 2695 this.cursor = cursor;
2484 //TODO null 2696 if (!isEnabled()) return;
2485 // view.addCursorRect(view.frame(), cursor.handle); 2697 display.setCursor (display.currentControl);
2486 } 2698 }
2487 2699
2488 void setDefaultFont () { 2700 void setDefaultFont () {
2489 // if (display.smallFonts) setFontStyle (defaultFont ()); 2701 // if (display.smallFonts) setFontStyle (defaultFont ());
2490 } 2702 }
2529 checkWidget(); 2741 checkWidget();
2530 if (((state & DISABLED) is 0) is enabled) return; 2742 if (((state & DISABLED) is 0) is enabled) return;
2531 Control control = null; 2743 Control control = null;
2532 bool fixFocus_ = false; 2744 bool fixFocus_ = false;
2533 if (!enabled) { 2745 if (!enabled) {
2534 // if (display.focusEvent !is DWT.FocusOut) { 2746 control = display.getFocusControl ();
2535 control = display.getFocusControl (); 2747 fixFocus = isFocusAncestor (control);
2536 fixFocus_ = isFocusAncestor (control);
2537 // }
2538 } 2748 }
2539 if (enabled) { 2749 if (enabled) {
2540 state &= ~DISABLED; 2750 state &= ~DISABLED;
2541 } else { 2751 } else {
2542 state |= DISABLED; 2752 state |= DISABLED;
2639 // fontStyle.flags &= ~OS.kControlUseForeColorMask; 2849 // fontStyle.flags &= ~OS.kControlUseForeColorMask;
2640 // } 2850 // }
2641 // OS.SetControlFontStyle (control, fontStyle); 2851 // OS.SetControlFontStyle (control, fontStyle);
2642 } 2852 }
2643 2853
2854 void setFrameOrigin (int /*long*/ id, int /*long*/ sel, NSPoint point) {
2855 NSView topView = topView ();
2856 if (topView.id !is id) {
2857 super.setFrameOrigin(id, sel, point);
2858 return;
2859 }
2860 NSRect frame = topView.frame();
2861 super.setFrameOrigin(id, sel, point);
2862 if (frame.x !is point.x || frame.y !is point.y) {
2863 moved ();
2864 }
2865 }
2866
2867 void setFrameSize (int /*long*/ id, int /*long*/ sel, NSSize size) {
2868 NSView topView = topView ();
2869 if (topView.id !is id) {
2870 super.setFrameSize(id, sel, size);
2871 return;
2872 }
2873 NSRect frame = topView.frame();
2874 super.setFrameSize(id, sel, size);
2875 if (frame.width !is size.width || frame.height !is size.height) {
2876 resized ();
2877 }
2878 }
2879
2644 /** 2880 /**
2645 * Sets the layout data associated with the receiver to the argument. 2881 * Sets the layout data associated with the receiver to the argument.
2646 * 2882 *
2647 * @param layoutData the new layout data for the receiver. 2883 * @param layoutData the new layout data for the receiver.
2648 * 2884 *
2763 Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell (); 2999 Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell ();
2764 if (oldShell !is newShell || oldDecorations !is newDecorations) { 3000 if (oldShell !is newShell || oldDecorations !is newDecorations) {
2765 Menu [] menus = oldShell.findMenus (this); 3001 Menu [] menus = oldShell.findMenus (this);
2766 fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); 3002 fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
2767 } 3003 }
2768 // int topHandle = topHandle (); 3004 NSView topView = topView ();
2769 // OS.HIViewAddSubview (parent.handle, topHandle); 3005 topView.retain();
2770 // OS.HIViewSetVisible (topHandle, (state & HIDDEN) is 0); 3006 topView.removeFromSuperview();
2771 // OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0); 3007 parent.contentView().addSubview(topView, OS.NSWindowBelow, null);
3008 topView.release();
2772 this.parent = parent; 3009 this.parent = parent;
2773 return true; 3010 return true;
2774 } 3011 }
2775 3012
2776 /** 3013 /**
2811 } 3048 }
2812 drawCount++; 3049 drawCount++;
2813 } 3050 }
2814 } 3051 }
2815 3052
3053 /**
3054 * Sets the shape of the control to the region specified
3055 * by the argument. When the argument is null, the
3056 * default shape of the control is restored.
3057 *
3058 * @param region the region that defines the shape of the control (or null)
3059 *
3060 * @exception IllegalArgumentException <ul>
3061 * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
3062 * </ul>
3063 * @exception DWTException <ul>
3064 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3065 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
3066 * </ul>
3067 *
3068 * @since 3.4
3069 */
2816 public void setRegion (Region region) { 3070 public void setRegion (Region region) {
2817 checkWidget (); 3071 checkWidget ();
2818 if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 3072 if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
2819 this.region = region; 3073 this.region = region;
2820 // redrawWidget (handle, true); 3074 // redrawWidget (handle, true);
2939 * the focus control. 3193 * the focus control.
2940 */ 3194 */
2941 Control control = null; 3195 Control control = null;
2942 bool fixFocus_ = false; 3196 bool fixFocus_ = false;
2943 if (!visible) { 3197 if (!visible) {
2944 // if (display.focusEvent !is DWT.FocusOut) { 3198 control = display.getFocusControl ();
2945 control = display.getFocusControl (); 3199 fixFocus = isFocusAncestor (control);
2946 fixFocus_ = isFocusAncestor (control);
2947 // }
2948 } 3200 }
2949 topView().setHidden(!visible); 3201 topView().setHidden(!visible);
2950 if (!visible) { 3202 if (!visible) {
2951 /* 3203 /*
2952 * It is possible (but unlikely), that application 3204 * It is possible (but unlikely), that application
2958 } 3210 }
2959 if (fixFocus_) fixFocus (control); 3211 if (fixFocus_) fixFocus (control);
2960 } 3212 }
2961 3213
2962 void setZOrder () { 3214 void setZOrder () {
2963 // int topHandle = topHandle (); 3215 NSView topView = topView ();
2964 // int parentHandle = parent.handle; 3216 parent.contentView().addSubview(topView, OS.NSWindowBelow, null);
2965 // OS.HIViewAddSubview (parentHandle, topHandle);
2966 // OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
2967 // Rect rect = getInset ();
2968 // rect.right = rect.left;
2969 // rect.bottom = rect.top;
2970 // OS.SetControlBounds (topHandle, rect);
2971 } 3217 }
2972 3218
2973 void setZOrder (Control control, bool above) { 3219 void setZOrder (Control control, bool above) {
2974 NSView otherView = control is null ? null : control.topView (); 3220 NSView otherView = control is null ? null : control.topView ();
2975 view.retain(); 3221 view.retain();
2976 view.removeFromSuperview(); 3222 view.removeFromSuperview();
2977 parent.contentView().addSubview_positioned_relativeTo_(view, above ? NSWindowAbove : NSWindowBelow, otherView); 3223 parent.contentView().addSubview(view, above ? NSWindowAbove : NSWindowBelow, otherView);
2978 view.release(); 3224 view.release();
2979 } 3225 }
2980 3226
2981 void sort (int [] items) { 3227 void sort (int [] items) {
2982 /* Shell Sort from K&R, pg 108 */ 3228 /* Shell Sort from K&R, pg 108 */
3099 all = true; 3345 all = true;
3100 detail = DWT.TRAVERSE_RETURN; 3346 detail = DWT.TRAVERSE_RETURN;
3101 break; 3347 break;
3102 } 3348 }
3103 case 48: /* Tab */ { 3349 case 48: /* Tab */ {
3104 int modifiers = display.lastModifiers; 3350 int /*long*/ modifiers = theEvent.modifierFlags ();
3105 bool next = (modifiers & OS.NSShiftKeyMask) is 0; 3351 bool next = (modifiers & OS.NSShiftKeyMask) is 0;
3106 detail = next ? DWT.TRAVERSE_TAB_NEXT : DWT.TRAVERSE_TAB_PREVIOUS; 3352 detail = next ? DWT.TRAVERSE_TAB_NEXT : DWT.TRAVERSE_TAB_PREVIOUS;
3107 break; 3353 break;
3108 } 3354 }
3109 case 126: /* Up arrow */ 3355 case 126: /* Up arrow */
3115 break; 3361 break;
3116 } 3362 }
3117 case 116: /* Page up */ 3363 case 116: /* Page up */
3118 case 121: /* Page down */ { 3364 case 121: /* Page down */ {
3119 all = true; 3365 all = true;
3120 // int [] modifiers = new int [1]; 3366 int /*long*/ modifiers = theEvent.modifierFlags ();
3121 // OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers); 3367 if ((modifiers & OS.NSControlKeyMask) is 0) return false;
3122 // if ((modifiers [0] & OS.controlKey) is 0) return false; 3368 detail = key is 121 /* Page down */ ? DWT.TRAVERSE_PAGE_NEXT : DWT.TRAVERSE_PAGE_PREVIOUS;
3123 // detail = key is 121 /* Page down */ ? DWT.TRAVERSE_PAGE_NEXT : DWT.TRAVERSE_PAGE_PREVIOUS;
3124 break; 3369 break;
3125 } 3370 }
3126 default: 3371 default:
3127 return false; 3372 return false;
3128 } 3373 }
3142 } while (all && control !is null); 3387 } while (all && control !is null);
3143 return false; 3388 return false;
3144 } 3389 }
3145 3390
3146 int traversalCode (short key, NSEvent theEvent) { 3391 int traversalCode (short key, NSEvent theEvent) {
3147 int code = DWT.TRAVERSE_RETURN | DWT.TRAVERSE_TAB_NEXT | DWT.TRAVERSE_TAB_PREVIOUS; 3392 int code = DWT.TRAVERSE_RETURN | DWT.TRAVERSE_TAB_NEXT | DWT.TRAVERSE_TAB_PREVIOUS | DWT.TRAVERSE_PAGE_NEXT | DWT.TRAVERSE_PAGE_PREVIOUS;
3148 Shell shell = getShell (); 3393 Shell shell = getShell ();
3149 if (shell.parent !is null) code |= DWT.TRAVERSE_ESCAPE; 3394 if (shell.parent !is null) code |= DWT.TRAVERSE_ESCAPE;
3150 return code; 3395 return code;
3151 } 3396 }
3152 3397
3290 } 3535 }
3291 3536
3292 void update (bool all) { 3537 void update (bool all) {
3293 // checkWidget(); 3538 // checkWidget();
3294 //TODO - not all 3539 //TODO - not all
3295 // OS.HIViewRender (handle); 3540 view.displayIfNeeded ();
3296 } 3541 }
3297 3542
3298 void updateBackgroundMode () { 3543 void updateBackgroundMode () {
3299 int oldState = state & PARENT_BACKGROUND; 3544 int oldState = state & PARENT_BACKGROUND;
3300 checkBackground (); 3545 checkBackground ();