@@ -424,7 +424,246 @@ public void run() {
424424 display.dispose ();
425425 }
426426 // */
427+ public void testCoolBarItemWrapControlSize () {
428+ Display display = new Display ();
429+ final Shell shell = new Shell (display );
430+ shell .setLayout (new GridLayout ());
431+
432+ final CoolBar bar5 = new CoolBar (shell , SWT .BORDER );
433+ final CoolItem toolItem5 = new CoolItem (bar5 , SWT .NONE );
434+ final Label label5 = new Label (bar5 , SWT .NONE );
435+ label5 .setText ("Hello World" );
436+ toolItem5 .setControl (label5 );
437+ toolItem5 .setPreferredSize (200 , 24 );
438+ final CoolItem toolItem52 = new CoolItem (bar5 , SWT .NONE );
439+ final Label label52 = new Label (bar5 , SWT .NONE );
440+ label52 .setText ("Hello World" );
441+ toolItem52 .setControl (label52 );
442+ toolItem52 .setPreferredSize (100 , 24 );
443+ final CoolItem toolItem53 = new CoolItem (bar5 , SWT .NONE );
444+ final Label label53 = new Label (bar5 , SWT .NONE );
445+ label53 .setText ("World" );
446+ toolItem53 .setControl (label53 );
447+ toolItem53 .setPreferredSize (60 , 24 );
448+ final CoolItem toolItem54 = new CoolItem (bar5 , SWT .NONE );
449+ final Label label54 = new Label (bar5 , SWT .NONE );
450+ label54 .setText ("World" );
451+ toolItem54 .setControl (label54 );
452+ toolItem54 .setPreferredSize (60 , 24 );
453+ bar5 .setWrapIndices (new int [] { 3 });
454+
455+ final CoolBar bar6 = new CoolBar (shell , SWT .BORDER );
456+ final CoolItem toolItem6 = new CoolItem (bar6 , SWT .NONE );
457+ final Text text6 = new Text (bar6 , SWT .BORDER );
458+ toolItem6 .setControl (text6 );
459+ toolItem6 .setPreferredSize (200 , 24 );
460+ final CoolItem toolItem62 = new CoolItem (bar6 , SWT .NONE );
461+ final Text text62 = new Text (bar6 , SWT .BORDER );
462+ toolItem62 .setControl (text62 );
463+ toolItem62 .setPreferredSize (120 , 24 );
464+ final CoolItem toolItem63 = new CoolItem (bar6 , SWT .NONE );
465+ final Text text63 = new Text (bar6 , SWT .BORDER );
466+ toolItem63 .setControl (text63 );
467+ toolItem63 .setPreferredSize (100 , 24 );
468+ final CoolItem toolItem64 = new CoolItem (bar6 , SWT .NONE );
469+ final Text text64 = new Text (bar6 , SWT .BORDER );
470+ toolItem64 .setControl (text64 );
471+ toolItem64 .setPreferredSize (160 , 24 );
472+ final CoolItem toolItem65 = new CoolItem (bar6 , SWT .NONE );
473+ final Text text65 = new Text (bar6 , SWT .BORDER );
474+ toolItem65 .setControl (text65 );
475+ toolItem65 .setPreferredSize (30 , 24 );
476+ bar6 .setWrapIndices (new int [] { 2 });
477+ shell .pack ();
478+ shell .setLocation (320 , 0 );
479+ shell .open ();
480+ AsyncSWT .waitLayout (shell , new AsyncTestRunnable (this ) {
481+ public void run () {
482+ System .out .println (bar5 .getSize ());
483+ System .out .println (bar6 .getSize ());
484+ System .out .println (label5 .getBounds ());
485+ System .out .println (text6 .getBounds ());
486+
487+ System .out .println (label52 .getBounds ());
488+ System .out .println (text62 .getBounds ());
489+ System .out .println (label53 .getBounds ());
490+ System .out .println (text63 .getBounds ());
491+ System .out .println (label54 .getBounds ());
492+ System .out .println (text64 .getBounds ());
493+ System .out .println (text65 .getBounds ());
494+
495+ assertEquals (bar5 .getSize (), new Point (368 , 54 ));
496+ assertEquals (bar6 .getSize (), new Point (326 , 54 ));
497+ assertEquals (label5 .getBounds (), new Rectangle (9 , 0 , 187 , 24 ));
498+ assertEquals (text6 .getBounds (), new Rectangle (9 , 0 , 187 , 24 ));
499+ assertEquals (label52 .getBounds (), new Rectangle (211 , 0 , 87 , 24 ));
500+ assertEquals (text62 .getBounds (), new Rectangle (211 , 0 , 107 , 24 ));
501+ assertEquals (label53 .getBounds (), new Rectangle (313 , 0 , 47 , 24 ));
502+ assertEquals (text63 .getBounds (), new Rectangle (9 , 26 , 87 , 24 ));
503+ assertEquals (label54 .getBounds (), new Rectangle (9 , 26 , 351 , 24 ));
504+ assertEquals (text64 .getBounds (), new Rectangle (111 , 26 , 147 , 24 ));
505+ assertEquals (text65 .getBounds (), new Rectangle (273 , 26 , 45 , 24 ));
506+ }
507+ });
508+ display .dispose ();
509+ }
510+
427511
512+ public void testCoolBarItemWrap3 () {
513+ Display display = new Display ();
514+ final Shell shell = new Shell (display );
515+ shell .setLayout (new GridLayout ());
516+
517+ final CoolBar bar5 = new CoolBar (shell , SWT .BORDER );
518+ final CoolItem toolItem5 = new CoolItem (bar5 , SWT .NONE );
519+ Label label5 = new Label (bar5 , SWT .NONE );
520+ label5 .setText ("Hello World" );
521+ toolItem5 .setControl (label5 );
522+ toolItem5 .setPreferredSize (200 , 24 );
523+ final CoolItem toolItem52 = new CoolItem (bar5 , SWT .NONE );
524+ Label label52 = new Label (bar5 , SWT .NONE );
525+ label52 .setText ("Hello World" );
526+ toolItem52 .setControl (label52 );
527+ toolItem52 .setPreferredSize (100 , 24 );
528+ final CoolItem toolItem53 = new CoolItem (bar5 , SWT .NONE );
529+ Label label53 = new Label (bar5 , SWT .NONE );
530+ label53 .setText ("World" );
531+ toolItem53 .setControl (label53 );
532+ toolItem53 .setPreferredSize (60 , 24 );
533+ final CoolItem toolItem54 = new CoolItem (bar5 , SWT .NONE );
534+ Label label54 = new Label (bar5 , SWT .NONE );
535+ label54 .setText ("World" );
536+ toolItem54 .setControl (label54 );
537+ toolItem54 .setPreferredSize (60 , 24 );
538+ bar5 .setWrapIndices (new int [] { 3 });
539+
540+ final CoolBar bar6 = new CoolBar (shell , SWT .BORDER );
541+ final CoolItem toolItem6 = new CoolItem (bar6 , SWT .NONE );
542+ Text text6 = new Text (bar6 , SWT .BORDER );
543+ toolItem6 .setControl (text6 );
544+ toolItem6 .setPreferredSize (200 , 24 );
545+ final CoolItem toolItem62 = new CoolItem (bar6 , SWT .NONE );
546+ Text text62 = new Text (bar6 , SWT .BORDER );
547+ toolItem62 .setControl (text62 );
548+ toolItem62 .setPreferredSize (120 , 24 );
549+ final CoolItem toolItem63 = new CoolItem (bar6 , SWT .NONE );
550+ Text text63 = new Text (bar6 , SWT .BORDER );
551+ toolItem63 .setControl (text63 );
552+ toolItem63 .setPreferredSize (100 , 24 );
553+ final CoolItem toolItem64 = new CoolItem (bar6 , SWT .NONE );
554+ Text text64 = new Text (bar6 , SWT .BORDER );
555+ toolItem64 .setControl (text64 );
556+ toolItem64 .setPreferredSize (160 , 24 );
557+ final CoolItem toolItem65 = new CoolItem (bar6 , SWT .NONE );
558+ Text text65 = new Text (bar6 , SWT .BORDER );
559+ toolItem65 .setControl (text65 );
560+ toolItem65 .setPreferredSize (30 , 24 );
561+ bar6 .setWrapIndices (new int [] { 2 });
562+ shell .pack ();
563+ shell .setLocation (320 , 0 );
564+ shell .open ();
565+ AsyncSWT .waitLayout (shell , new AsyncTestRunnable (this ) {
566+ public void run () {
567+ System .out .println (bar5 .getSize ());
568+ System .out .println (bar6 .getSize ());
569+ System .out .println (toolItem5 .getBounds ());
570+ System .out .println (toolItem6 .getBounds ());
571+
572+ System .out .println (toolItem52 .getBounds ());
573+ System .out .println (toolItem62 .getBounds ());
574+ System .out .println (toolItem53 .getBounds ());
575+ System .out .println (toolItem63 .getBounds ());
576+ System .out .println (toolItem54 .getBounds ());
577+ System .out .println (toolItem64 .getBounds ());
578+ System .out .println (toolItem65 .getBounds ());
579+
580+ assertEquals (bar5 .getSize (), new Point (368 , 54 ));
581+ assertEquals (bar6 .getSize (), new Point (326 , 54 ));
582+ assertEquals (toolItem5 .getBounds (), new Rectangle (0 , 0 , 202 , 24 ));
583+ assertEquals (toolItem6 .getBounds (), new Rectangle (0 , 0 , 202 , 24 ));
584+ assertEquals (toolItem52 .getBounds (), new Rectangle (202 , 0 , 102 , 24 ));
585+ assertEquals (toolItem62 .getBounds (), new Rectangle (202 , 0 , 120 , 24 ));
586+ assertEquals (toolItem53 .getBounds (), new Rectangle (304 , 0 , 60 , 24 ));
587+ assertEquals (toolItem63 .getBounds (), new Rectangle (0 , 26 , 102 , 24 ));
588+ assertEquals (toolItem54 .getBounds (), new Rectangle (0 , 26 , 364 , 24 ));
589+ assertEquals (toolItem64 .getBounds (), new Rectangle (102 , 26 , 162 , 24 ));
590+ assertEquals (toolItem65 .getBounds (), new Rectangle (264 , 26 , 58 , 24 ));
591+ }
592+ });
593+ display .dispose ();
594+ }
595+
596+ public void testCoolBarItemWrap2 () {
597+ Display display = new Display ();
598+ final Shell shell = new Shell (display );
599+ shell .setLayout (new GridLayout ());
600+
601+ final CoolBar bar5 = new CoolBar (shell , SWT .BORDER );
602+ final CoolItem toolItem5 = new CoolItem (bar5 , SWT .NONE );
603+ Label label5 = new Label (bar5 , SWT .NONE );
604+ label5 .setText ("Hello World" );
605+ toolItem5 .setControl (label5 );
606+ toolItem5 .setPreferredSize (200 , 24 );
607+ final CoolItem toolItem52 = new CoolItem (bar5 , SWT .NONE );
608+ Label label52 = new Label (bar5 , SWT .NONE );
609+ label52 .setText ("Hello World" );
610+ toolItem52 .setControl (label52 );
611+ toolItem52 .setPreferredSize (100 , 24 );
612+ final CoolItem toolItem53 = new CoolItem (bar5 , SWT .NONE );
613+ Label label53 = new Label (bar5 , SWT .NONE );
614+ label53 .setText ("World" );
615+ toolItem53 .setControl (label53 );
616+ toolItem53 .setPreferredSize (60 , 24 );
617+
618+ final CoolBar bar6 = new CoolBar (shell , SWT .BORDER );
619+ final CoolItem toolItem6 = new CoolItem (bar6 , SWT .NONE );
620+ Text text6 = new Text (bar6 , SWT .BORDER );
621+ toolItem6 .setControl (text6 );
622+ toolItem6 .setPreferredSize (200 , 24 );
623+ final CoolItem toolItem62 = new CoolItem (bar6 , SWT .NONE );
624+ Text text62 = new Text (bar6 , SWT .BORDER );
625+ toolItem62 .setControl (text62 );
626+ toolItem62 .setPreferredSize (120 , 24 );
627+ final CoolItem toolItem63 = new CoolItem (bar6 , SWT .NONE );
628+ Text text63 = new Text (bar6 , SWT .BORDER );
629+ toolItem63 .setControl (text63 );
630+ toolItem63 .setPreferredSize (100 , 24 );
631+ final CoolItem toolItem64 = new CoolItem (bar6 , SWT .NONE );
632+ Text text64 = new Text (bar6 , SWT .BORDER );
633+ toolItem64 .setControl (text64 );
634+ toolItem64 .setPreferredSize (160 , 24 );
635+ bar6 .setWrapIndices (new int [] { 2 });
636+ shell .pack ();
637+ shell .setLocation (320 , 0 );
638+ shell .open ();
639+ AsyncSWT .waitLayout (shell , new AsyncTestRunnable (this ) {
640+ public void run () {
641+ System .out .println (bar5 .getSize ());
642+ System .out .println (bar6 .getSize ());
643+ System .out .println (toolItem5 .getBounds ());
644+ System .out .println (toolItem6 .getBounds ());
645+
646+ System .out .println (toolItem52 .getBounds ());
647+ System .out .println (toolItem62 .getBounds ());
648+ System .out .println (toolItem53 .getBounds ());
649+ System .out .println (toolItem63 .getBounds ());
650+ System .out .println (toolItem64 .getBounds ());
651+
652+ assertEquals (bar5 .getSize (), new Point (368 , 28 ));
653+ assertEquals (bar6 .getSize (), new Point (326 , 54 ));
654+ assertEquals (toolItem5 .getBounds (), new Rectangle (0 , 0 , 202 , 24 ));
655+ assertEquals (toolItem6 .getBounds (), new Rectangle (0 , 0 , 202 , 24 ));
656+ assertEquals (toolItem52 .getBounds (), new Rectangle (202 , 0 , 102 , 24 ));
657+ assertEquals (toolItem62 .getBounds (), new Rectangle (202 , 0 , 120 , 24 ));
658+ assertEquals (toolItem53 .getBounds (), new Rectangle (304 , 0 , 60 , 24 ));
659+ assertEquals (toolItem63 .getBounds (), new Rectangle (0 , 26 , 102 , 24 ));
660+ assertEquals (toolItem64 .getBounds (), new Rectangle (102 , 26 , 220 , 24 ));
661+ }
662+ });
663+ display .dispose ();
664+ }
665+
666+
428667 public void testCoolBarItemWrap () {
429668 Display display = new Display ();
430669 final Shell shell = new Shell (display );
0 commit comments