Mercurial > projects > dwt-mac
comparison dwt/widgets/Composite.d @ 47:8615c76f10e4
Updated dwt.widgets.Compisite to 3.514
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 05 Dec 2008 16:23:23 +0100 |
parents | d8635bb48c7c |
children | 62202ce0039f |
comparison
equal
deleted
inserted
replaced
46:cfa563df4fdd | 47:8615c76f10e4 |
---|---|
26 import dwt.internal.cocoa.NSScrollView; | 26 import dwt.internal.cocoa.NSScrollView; |
27 import dwt.internal.cocoa.NSView; | 27 import dwt.internal.cocoa.NSView; |
28 import dwt.internal.cocoa.OS; | 28 import dwt.internal.cocoa.OS; |
29 import dwt.internal.cocoa.SWTScrollView; | 29 import dwt.internal.cocoa.SWTScrollView; |
30 import dwt.internal.cocoa.SWTView; | 30 import dwt.internal.cocoa.SWTView; |
31 import dwt.internal.cocoa.id; | 31 import cocoa = dwt.internal.cocoa.id; |
32 | 32 |
33 import dwt.dwthelper.utils; | 33 import dwt.dwthelper.utils; |
34 import dwt.internal.cocoa.NSInteger; | 34 import dwt.internal.c.Carbon; |
35 import dwt.internal.objc.cocoa.Cocoa; | |
35 import dwt.widgets.Control; | 36 import dwt.widgets.Control; |
36 import dwt.widgets.Decorations; | 37 import dwt.widgets.Decorations; |
37 import dwt.widgets.Display; | 38 import dwt.widgets.Display; |
38 import dwt.widgets.Event; | 39 import dwt.widgets.Event; |
39 import dwt.widgets.Layout; | 40 import dwt.widgets.Layout; |
123 Control [] children = new Control [count]; | 124 Control [] children = new Control [count]; |
124 if (count is 0) return children; | 125 if (count is 0) return children; |
125 int j = 0; | 126 int j = 0; |
126 for (int i=0; i<count; i++){ | 127 for (int i=0; i<count; i++){ |
127 Widget widget = display.getWidget (views.objectAtIndex (count - i - 1).id); | 128 Widget widget = display.getWidget (views.objectAtIndex (count - i - 1).id); |
128 if (widget !is null && widget !is this && widget instanceof Control) { | 129 if (widget !is null && widget !is this && cast(Control) widget) { |
129 children [j++] = cast(Control) widget; | 130 children [j++] = cast(Control) widget; |
130 } | 131 } |
131 } | 132 } |
132 if (j is count) return children; | 133 if (j is count) return children; |
133 Control [] newChildren = new Control [j]; | 134 Control [] newChildren = new Control [j]; |
151 } | 152 } |
152 tabList = newList; | 153 tabList = newList; |
153 return tabList; | 154 return tabList; |
154 } | 155 } |
155 | 156 |
156 bool acceptsFirstResponder (int /*long*/ id, int /*long*/ sel) { | 157 bool acceptsFirstResponder (objc.id id, objc.SEL sel) { |
157 if ((state & CANVAS) !is 0) { | 158 if ((state & CANVAS) !is 0) { |
158 return ((style & DWT.NO_FOCUS) is 0); | 159 return ((style & DWT.NO_FOCUS) is 0); |
159 } | 160 } |
160 return super.acceptsFirstResponder (id, sel); | 161 return super.acceptsFirstResponder (id, sel); |
161 } | 162 } |
162 | 163 |
163 int accessibilityAttributeNames(int /*long*/ id, int /*long*/ sel) { | 164 objc.id accessibilityAttributeNames(objc.id id, objc.SEL sel) { |
164 | 165 |
165 if (id is view.id) { | 166 if (id is view.id) { |
166 if (accessible !is null) { | 167 if (accessible !is null) { |
167 // If there is an accessible, it may provide its own list of attributes if it's a lightweight control. | 168 // If there is an accessible, it may provide its own list of attributes if it's a lightweight control. |
168 // If not, let Cocoa handle it for this view. | 169 // If not, let Cocoa handle it for this view. |
169 id returnObject = accessible.internal_accessibilityAttributeNames(ACC.CHILDID_SELF); | 170 cocoa.id returnObject = accessible.internal_accessibilityAttributeNames(ACC.CHILDID_SELF); |
170 if (returnObject !is null) return returnObject.id; | 171 if (returnObject !is null) return returnObject.id; |
171 } | 172 } |
172 } | 173 } |
173 | 174 |
174 return super.accessibilityAttributeNames(id, sel); | 175 return super.accessibilityAttributeNames(id, sel); |
175 } | 176 } |
176 | 177 |
177 bool accessibilityIsIgnored(int /*long*/ id, int /*long*/ sel) { | 178 bool accessibilityIsIgnored(objc.id id, objc.SEL sel) { |
178 // If we have an accessible and it represents a valid accessible role, this view is not ignored. | 179 // If we have an accessible and it represents a valid accessible role, this view is not ignored. |
179 if (view !is null && id is view.id) { | 180 if (view !is null && id is view.id) { |
180 if (accessible !is null) { | 181 if (accessible !is null) { |
181 id role = accessible.internal_accessibilityAttributeValue(OS.NSAccessibilityRoleAttribute, ACC.CHILDID_SELF); | 182 cocoa.id role = accessible.internal_accessibilityAttributeValue(OS.NSAccessibilityRoleAttribute, ACC.CHILDID_SELF); |
182 if (role !is null) return false; | 183 if (role !is null) return false; |
183 } | 184 } |
184 } | 185 } |
185 | 186 |
186 return super.accessibilityIsIgnored(id, sel); | 187 return super.accessibilityIsIgnored(id, sel); |
187 } | 188 } |
188 | 189 |
189 /** | 190 /** |
190 * Clears any data that has been cached by a Layout for all widgets that | 191 * Clears any data that has been cached by a Layout for all widgets that |
191 * are in the parent hierarchy of the changed control up to and including the | 192 * are in the parent hierarchy of the changed control up to and including the |
293 widget.initWithFrame (rect); | 294 widget.initWithFrame (rect); |
294 // widget.setFocusRingType(OS.NSFocusRingTypeExterior); | 295 // widget.setFocusRingType(OS.NSFocusRingTypeExterior); |
295 view = widget; | 296 view = widget; |
296 } | 297 } |
297 | 298 |
298 void drawWidget (int /*long*/ id, NSRect rect) { | 299 void drawWidget (objc.id id, NSRect rect) { |
299 if ((state & CANVAS) !is 0) { | 300 if ((state & CANVAS) !is 0) { |
300 if ((style & DWT.NO_BACKGROUND) is 0) { | 301 if ((style & DWT.NO_BACKGROUND) is 0) { |
301 NSGraphicsContext context = NSGraphicsContext.currentContext(); | 302 NSGraphicsContext context = NSGraphicsContext.currentContext(); |
302 fillBackground (view, context, rect); | 303 fillBackground (view, context, rect); |
303 } | 304 } |
509 public bool isLayoutDeferred () { | 510 public bool isLayoutDeferred () { |
510 checkWidget (); | 511 checkWidget (); |
511 return findDeferredControl () !is null; | 512 return findDeferredControl () !is null; |
512 } | 513 } |
513 | 514 |
514 bool isOpaque (int /*long*/ id, int /*long*/ sel) { | 515 bool isOpaque (objc.id id, objc.SEL sel) { |
515 if ((state & CANVAS) !is 0) { | 516 if ((state & CANVAS) !is 0) { |
516 if (id is view.id) { | 517 if (id is view.id) { |
517 if (region is null && background !is null && background.handle[3] is 1) { | 518 if (region is null && background !is null && background.handle[3] is 1) { |
518 return true; | 519 return true; |
519 } | 520 } |
525 bool isTabGroup () { | 526 bool isTabGroup () { |
526 if ((state & CANVAS) !is 0) return true; | 527 if ((state & CANVAS) !is 0) return true; |
527 return super.isTabGroup (); | 528 return super.isTabGroup (); |
528 } | 529 } |
529 | 530 |
530 void keyDown (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { | 531 void keyDown (objc.id id, objc.SEL sel, objc.id theEvent) { |
531 if ((state & CANVAS) !is 0) { | 532 if ((state & CANVAS) !is 0) { |
532 NSArray array = NSArray.arrayWithObject (new NSEvent (theEvent)); | 533 NSArray array = NSArray.arrayWithObject (new NSEvent (theEvent)); |
533 view.interpretKeyEvents (array); | 534 view.interpretKeyEvents (array); |
534 return; | 535 return; |
535 } | 536 } |
731 height = Math.max (height, rect.y + rect.height); | 732 height = Math.max (height, rect.y + rect.height); |
732 } | 733 } |
733 return new Point (width, height); | 734 return new Point (width, height); |
734 } | 735 } |
735 | 736 |
736 void pageDown(int /*long*/ id, int /*long*/ sel, int /*long*/ sender) { | 737 void pageDown(objc.id id, objc.SEL sel, objc.id sender) { |
737 if ((state & CANVAS) !is 0) return; | 738 if ((state & CANVAS) !is 0) return; |
738 super.pageDown(id, sel, sender); | 739 super.pageDown(id, sel, sender); |
739 } | 740 } |
740 | 741 |
741 void pageUp(int /*long*/ id, int /*long*/ sel, int /*long*/ sender) { | 742 void pageUp(objc.id id, objc.SEL sel, objc.id sender) { |
742 if ((state & CANVAS) !is 0) return; | 743 if ((state & CANVAS) !is 0) return; |
743 super.pageUp(id, sel, sender); | 744 super.pageUp(id, sel, sender); |
744 } | 745 } |
745 | 746 |
746 void reflectScrolledClipView (int /*long*/ id, int /*long*/ sel, int /*long*/ aClipView) { | 747 void reflectScrolledClipView (objc.id id, objc.SEL sel, objc.id aClipView) { |
747 if ((state & CANVAS) !is 0) return; | 748 if ((state & CANVAS) !is 0) return; |
748 super.reflectScrolledClipView (id, sel, aClipView); | 749 super.reflectScrolledClipView (id, sel, aClipView); |
749 } | 750 } |
750 | 751 |
751 void releaseChildren (bool destroy) { | 752 void releaseChildren (bool destroy) { |
775 markLayout (false, false); | 776 markLayout (false, false); |
776 updateLayout (false); | 777 updateLayout (false); |
777 } | 778 } |
778 } | 779 } |
779 | 780 |
780 void scrollWheel (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { | 781 void scrollWheel (objc.id id, objc.SEL sel, objc.id theEvent) { |
781 if ((state & CANVAS) !is 0) { | 782 if ((state & CANVAS) !is 0) { |
782 NSView view = scrollView !is null ? scrollView : this.view; | 783 NSView view = scrollView !is null ? scrollView : this.view; |
783 if (id is view.id) { | 784 if (id is view.id) { |
784 NSEvent nsEvent = new NSEvent(theEvent); | 785 NSEvent nsEvent = new NSEvent(theEvent); |
785 float /*double*/ delta = nsEvent.deltaY(); | 786 CGFloat delta = nsEvent.deltaY(); |
786 if (delta !is 0) { | 787 if (delta !is 0) { |
787 if (hooks (DWT.MouseWheel) || filters (DWT.MouseWheel)) { | 788 if (hooks (DWT.MouseWheel) || filters (DWT.MouseWheel)) { |
788 if (!sendMouseEvent(nsEvent, DWT.MouseWheel, true)) { | 789 if (!sendMouseEvent(nsEvent, DWT.MouseWheel, true)) { |
789 return; | 790 return; |
790 } | 791 } |
791 } | 792 } |
792 } | 793 } |
793 bool handled = false; | 794 bool handled = false; |
794 ScrollBar bar = verticalBar; | 795 ScrollBar bar = verticalBar; |
795 if (delta !is 0 && bar !is null && bar.getEnabled ()) { | 796 if (delta !is 0 && bar !is null && bar.getEnabled ()) { |
796 int selection = Math.max (0, (int)(0.5f + bar.getSelection () - bar.getIncrement () * delta)); | 797 int selection = Math.max (0, cast(int)(0.5f + bar.getSelection () - bar.getIncrement () * delta)); |
797 bar.setSelection (selection); | 798 bar.setSelection (selection); |
798 Event event = new Event (); | 799 Event event = new Event (); |
799 event.detail = delta > 0 ? DWT.PAGE_UP : DWT.PAGE_DOWN; | 800 event.detail = delta > 0 ? DWT.PAGE_UP : DWT.PAGE_DOWN; |
800 bar.sendEvent (DWT.Selection, event); | 801 bar.sendEvent (DWT.Selection, event); |
801 handled = true; | 802 handled = true; |
802 } | 803 } |
803 bar = horizontalBar; | 804 bar = horizontalBar; |
804 delta = nsEvent.deltaX (); | 805 delta = nsEvent.deltaX (); |
805 if (delta !is 0 && bar !is null && bar.getEnabled ()) { | 806 if (delta !is 0 && bar !is null && bar.getEnabled ()) { |
806 int selection = Math.max (0, (int)(0.5f + bar.getSelection () - bar.getIncrement () * delta)); | 807 int selection = Math.max (0, cast(int)(0.5f + bar.getSelection () - bar.getIncrement () * delta)); |
807 bar.setSelection (selection); | 808 bar.setSelection (selection); |
808 Event event = new Event (); | 809 Event event = new Event (); |
809 event.detail = delta > 0 ? DWT.PAGE_UP : DWT.PAGE_DOWN; | 810 event.detail = delta > 0 ? DWT.PAGE_UP : DWT.PAGE_DOWN; |
810 bar.sendEvent (DWT.Selection, event); | 811 bar.sendEvent (DWT.Selection, event); |
811 handled = true; | 812 handled = true; |