@@ -137,13 +137,14 @@ public Composite (Composite parent, int style) {
137137Control [] _getTabList () {
138138 if (tabList == null ) return tabList ;
139139 int count = 0 ;
140- for (int i =0 ; i <tabList .length ; i ++) {
140+ int length = tabList .length ;
141+ for (int i =0 ; i <length ; i ++) {
141142 if (!tabList [i ].isDisposed ()) count ++;
142143 }
143- if (count == tabList . length ) return tabList ;
144+ if (count == length ) return tabList ;
144145 Control [] newList = new Control [count ];
145146 int index = 0 ;
146- for (int i =0 ; i <tabList . length ; i ++) {
147+ for (int i =0 ; i <length ; i ++) {
147148 if (!tabList [i ].isDisposed ()) {
148149 newList [index ++] = tabList [i ];
149150 }
@@ -174,7 +175,8 @@ public Composite (Composite parent, int style) {
174175public void changed (Control [] changed ) {
175176 checkWidget ();
176177 if (changed == null ) error (SWT .ERROR_INVALID_ARGUMENT );
177- for (int i =0 ; i <changed .length ; i ++) {
178+ int length = changed .length ;
179+ for (int i =0 ; i < length ; i ++) {
178180 Control control = changed [i ];
179181 if (control == null ) error (SWT .ERROR_INVALID_ARGUMENT );
180182 if (control .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
@@ -187,7 +189,7 @@ public void changed (Control[] changed) {
187189 }
188190 if (!ancestor ) error (SWT .ERROR_INVALID_PARENT );
189191 }
190- for (int i =0 ; i <changed . length ; i ++) {
192+ for (int i =0 ; i < length ; i ++) {
191193 Control child = changed [i ];
192194 Composite composite = child .parent ;
193195 while (child != this ) {
@@ -279,6 +281,7 @@ protected void createHandle () {
279281 if (control == this ) return new Menu [0 ];
280282 Menu result [] = super .findMenus (control );
281283 Control [] children = _getChildren ();
284+
282285 for (int i =0 ; i <children .length ; i ++) {
283286 Control child = children [i ];
284287 Menu [] menuList = child .findMenus (control );
@@ -295,14 +298,16 @@ protected void createHandle () {
295298void fixChildren (Shell newShell , Shell oldShell , Decorations newDecorations , Decorations oldDecorations , Menu [] menus ) {
296299 super .fixChildren (newShell , oldShell , newDecorations , oldDecorations , menus );
297300 Control [] children = _getChildren ();
298- for (int i =0 ; i <children .length ; i ++) {
301+ int length = children .length ;
302+ for (int i =0 ; i < length ; i ++) {
299303 children [i ].fixChildren (newShell , oldShell , newDecorations , oldDecorations , menus );
300304 }
301305}
302306void fixChildrenList (Control control ) {
303- if (children == null || children .length == 0 ) return ;
307+ int length = children .length ;
308+ if (children == null || length == 0 ) return ;
304309 Control [] newChildren = new Control [0 ];
305- for (int i = 0 ; i < children . length ; i ++) {
310+ for (int i = 0 ; i < length ; i ++) {
306311 Control child = children [i ];
307312 if (child != null && child != control ) {
308313 newChildren [newChildren .length ] = child ;
@@ -380,7 +385,7 @@ int getChildrenCount () {
380385 */
381386 // TODO: search the children and filter out the essential children
382387// return count;
383- return children .length ;
388+ return _getChildren () .length ;
384389}
385390
386391/**
@@ -417,12 +422,13 @@ public Layout getLayout () {
417422 if (tabList == null ) {
418423 int count = 0 ;
419424 Control [] list =_getChildren ();
420- for (int i =0 ; i <list .length ; i ++) {
425+ int length = list .length ;
426+ for (int i =0 ; i < length ; i ++) {
421427 if (list [i ].isTabGroup ()) count ++;
422428 }
423429 tabList = new Control [count ];
424430 int index = 0 ;
425- for (int i =0 ; i <list . length ; i ++) {
431+ for (int i =0 ; i < length ; i ++) {
426432 if (list [i ].isTabGroup ()) {
427433 tabList [index ++] = list [i ];
428434 }
@@ -591,8 +597,9 @@ public void layout (Control [] changed) {
591597 checkWidget ();
592598 System .out .print ("control" );
593599 if (changed == null ) error (SWT .ERROR_INVALID_ARGUMENT );
594- Date d = new Date ();
595- for (int i =0 ; i <changed .length ; i ++) {
600+ Date d = new Date ();
601+ int length = changed .length ;
602+ for (int i =0 ; i < length ; i ++) {
596603 Control control = changed [i ];
597604 if (control == null ) error (SWT .ERROR_INVALID_ARGUMENT );
598605 if (control .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
@@ -609,7 +616,7 @@ public void layout (Control [] changed) {
609616 d = new Date ();
610617 int updateCount = 0 ;
611618 Composite [] update = new Composite [16 ];
612- for (int i =0 ; i <changed . length ; i ++) {
619+ for (int i =0 ; i < length ; i ++) {
613620 Control child = changed [i ];
614621 Composite composite = child .parent ;
615622 while (child != this ) {
@@ -643,8 +650,9 @@ void markLayout (boolean changed, boolean all) {
643650 if (changed ) state |= LAYOUT_CHANGED ;
644651 }
645652 if (all ) {
646- Control [] children = _getChildren ();
647- for (int i =0 ; i <children .length ; i ++) {
653+ Control [] children = _getChildren ();
654+ int length = children .length ;
655+ for (int i =0 ; i < length ; i ++) {
648656 children [i ].markLayout (changed , all );
649657 }
650658 }
@@ -654,7 +662,8 @@ Point minimumSize (int wHint, int hHint, boolean changed) {
654662 Control [] children = _getChildren ();
655663 //System.out.println("minimumSize@Composite");
656664 int width = 0 , height = 0 ;
657- for (int i =0 ; i <children .length ; i ++) {
665+ int length = children .length ;
666+ for (int i =0 ; i < length ; i ++) {
658667 //System.out.println(i + "..." + children [i]);
659668 Rectangle rect = children [i ].getBounds ();
660669 width = Math .max (width , rect .x + rect .width );
@@ -668,7 +677,8 @@ Point minimumSize (int wHint, int hHint, boolean changed) {
668677
669678void releaseChildren () {
670679 Control [] children = _getChildren ();
671- for (int i =0 ; i <children .length ; i ++) {
680+ int length = children .length ;
681+ for (int i =0 ; i <length ; i ++) {
672682 Control child = children [i ];
673683 if (!child .isDisposed ()) child .releaseResources ();
674684 }
@@ -692,7 +702,8 @@ protected void releaseWidget () {
692702 layout = null ;
693703 tabList = null ;
694704 if (lpwp != null ) {
695- for (int i = 0 ; i < lpwp .length ; i ++) {
705+ int length = lpwp .length ;
706+ for (int i = 0 ; i < length ; i ++) {
696707 lpwp [i ].hwnd = null ;
697708 lpwp [i ].hwndInsertAfter = null ;
698709 }
@@ -724,7 +735,8 @@ boolean resizeChildren (boolean defer, WINDOWPOS [] pwp) {
724735 //hdwp = OS.BeginDeferWindowPos (pwp.length);
725736 if (hdwp == 0 ) return false ;
726737 }
727- for (int i =0 ; i <pwp .length ; i ++) {
738+ int length = pwp .length ;
739+ for (int i =0 ; i <length ; i ++) {
728740 WINDOWPOS wp = pwp [i ];
729741 if (wp != null ) {
730742 /*
@@ -775,11 +787,12 @@ void resizeEmbeddedHandle(int embeddedHandle, int width, int height) {
775787boolean setFixedFocus () {
776788 checkWidget ();
777789 Control [] children = _getChildren ();
778- for (int i =0 ; i <children .length ; i ++) {
790+ int length = children .length ;
791+ for (int i =0 ; i <length ; i ++) {
779792 Control child = children [i ];
780793 if (child .setRadioFocus ()) return true ;
781794 }
782- for (int i =0 ; i <children . length ; i ++) {
795+ for (int i =0 ; i <length ; i ++) {
783796 Control child = children [i ];
784797 if (child .setFixedFocus ()) return true ;
785798 }
@@ -789,11 +802,12 @@ boolean setFixedFocus () {
789802public boolean setFocus () {
790803 checkWidget ();
791804 Control [] children = _getChildren ();
792- for (int i =0 ; i <children .length ; i ++) {
805+ int length = children .length ;
806+ for (int i =0 ; i <length ; i ++) {
793807 Control child = children [i ];
794808 if (child .setRadioFocus ()) return true ;
795809 }
796- for (int i =0 ; i <children . length ; i ++) {
810+ for (int i =0 ; i <length ; i ++) {
797811 Control child = children [i ];
798812 if (child .setFocus ()) return true ;
799813 }
@@ -865,14 +879,15 @@ public void setLayoutDeferred (boolean defer) {
865879public void setTabList (Control [] tabList ) {
866880 checkWidget ();
867881 if (tabList != null ) {
868- for (int i =0 ; i <tabList .length ; i ++) {
882+ int length = tabList .length ;
883+ for (int i =0 ; i <length ; i ++) {
869884 Control control = tabList [i ];
870885 if (control == null ) error (SWT .ERROR_INVALID_ARGUMENT );
871886 if (control .isDisposed ()) error (SWT .ERROR_INVALID_ARGUMENT );
872887 if (control .parent != this ) error (SWT .ERROR_INVALID_PARENT );
873888 }
874- Control [] newList = new Control [tabList . length ];
875- System .arraycopy (tabList , 0 , newList , 0 , tabList . length );
889+ Control [] newList = new Control [length ];
890+ System .arraycopy (tabList , 0 , newList , 0 , length );
876891 tabList = newList ;
877892 }
878893 this .tabList = tabList ;
@@ -898,11 +913,12 @@ boolean setTabGroupFocus () {
898913 }
899914 if (takeFocus && setTabItemFocus ()) return true ;
900915 Control [] children = _getChildren ();
901- for (int i =0 ; i <children .length ; i ++) {
916+ int length = children .length ;
917+ for (int i =0 ; i <length ; i ++) {
902918 Control child = children [i ];
903919 if (child .isTabItem () && child .setRadioFocus ()) return true ;
904920 }
905- for (int i =0 ; i <children . length ; i ++) {
921+ for (int i =0 ; i <length ; i ++) {
906922 Control child = children [i ];
907923 if (child .isTabItem () && child .setTabItemFocus ()) return true ;
908924 }
@@ -992,12 +1008,16 @@ void updateLayout (boolean resize, boolean all) {
9921008 boolean changed = (state & LAYOUT_CHANGED ) != 0 ;
9931009 state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED );
9941010 if (resize ) setResizeChildren (false );
995- layout .layout (this , changed );
1011+ // layout.layout (this, changed);
1012+ display .sendMessage (new MESSAGE (this , MESSAGE .CONTROL_LAYOUT , new boolean [] {resize , all }));
9961013 if (resize ) setResizeChildren (true );
9971014 }
1015+
1016+
9981017 if (all ) {
9991018 Control [] children = _getChildren ();
1000- for (int i =0 ; i <children .length ; i ++) {
1019+ int length = children .length ;
1020+ for (int i =0 ; i <length ; i ++) {
10011021// children [i].updateLayout (resize, all);
10021022 if (children [i ] instanceof Composite ) {
10031023// System.out.println("update Layout " + children[i]);
0 commit comments