Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 278195 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/internal/graphics/TextSizeDeterminationHandler.java (-7 / +16 lines)
Lines 22-29 Link Here
22
import org.eclipse.rwt.service.ISessionStore;
22
import org.eclipse.rwt.service.ISessionStore;
23
import org.eclipse.swt.custom.ScrolledComposite;
23
import org.eclipse.swt.custom.ScrolledComposite;
24
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.internal.graphics.TextSizeDetermination.ICalculationItem;
26
import org.eclipse.swt.internal.graphics.TextSizeDetermination.ICalculationItem;
26
import org.eclipse.swt.internal.graphics.TextSizeProbeStore.IProbe;
27
import org.eclipse.swt.internal.graphics.TextSizeProbeStore.IProbe;
28
import org.eclipse.swt.internal.widgets.IShellAdapter;
27
import org.eclipse.swt.internal.widgets.WidgetTreeVisitor;
29
import org.eclipse.swt.internal.widgets.WidgetTreeVisitor;
28
import org.eclipse.swt.internal.widgets.WidgetTreeVisitor.AllWidgetTreeVisitor;
30
import org.eclipse.swt.internal.widgets.WidgetTreeVisitor.AllWidgetTreeVisitor;
29
import org.eclipse.swt.widgets.*;
31
import org.eclipse.swt.widgets.*;
Lines 73-79 Link Here
73
          Shell[] shells = display.getShells();
75
          Shell[] shells = display.getShells();
74
          for( int i = 0; i < shells.length; i++ ) {
76
          for( int i = 0; i < shells.length; i++ ) {
75
            // TODO [fappel]: Think about a lighter recalculation trigger.
77
            // TODO [fappel]: Think about a lighter recalculation trigger.
76
            Point buffer = shells[ i ].getSize();
78
            Shell shell = shells[ i ];
79
            Rectangle bufferedBounds = shell.getBounds();
77
            AllWidgetTreeVisitor clearLayout = new AllWidgetTreeVisitor() {
80
            AllWidgetTreeVisitor clearLayout = new AllWidgetTreeVisitor() {
78
              public boolean doVisit( final Widget widget ) {
81
              public boolean doVisit( final Widget widget ) {
79
                if( widget instanceof Composite ) {
82
                if( widget instanceof Composite ) {
Lines 124-135 Link Here
124
                return true;
127
                return true;
125
              }
128
              }
126
            };
129
            };
127
            WidgetTreeVisitor.accept( shells[ i ], saveSCOrigins );
130
            WidgetTreeVisitor.accept( shell, saveSCOrigins );
128
            WidgetTreeVisitor.accept( shells[ i ], clearLayout );
131
            WidgetTreeVisitor.accept( shell, clearLayout );
129
            shells[ i ].setSize( buffer.x + 1000, buffer.y + 1000 );
132
            IShellAdapter shellAdapter
130
            WidgetTreeVisitor.accept( shells[ i ], clearLayout );
133
              = ( IShellAdapter )shell.getAdapter( IShellAdapter.class );
131
            shells[ i ].setSize( buffer );
134
            Rectangle bounds1000 = new Rectangle( bufferedBounds.x, 
132
            WidgetTreeVisitor.accept( shells[ i ], restoreSCOrigins );
135
                                                  bufferedBounds.y, 
136
                                                  bufferedBounds.width + 1000, 
137
                                                  bufferedBounds.height + 1000 );
138
            shellAdapter.setBounds( bounds1000 );
139
            WidgetTreeVisitor.accept( shell, clearLayout );
140
            shellAdapter.setBounds( bufferedBounds );
141
            WidgetTreeVisitor.accept( shell, restoreSCOrigins );
133
          }
142
          }
134
        }
143
        }
135
        if( event.getPhaseId() == PhaseId.RENDER ) {
144
        if( event.getPhaseId() == PhaseId.RENDER ) {
(-)src/org/eclipse/swt/internal/widgets/IShellAdapter.java (-1 / +2 lines)
Lines 18-25 Link Here
18
public interface IShellAdapter {
18
public interface IShellAdapter {
19
  
19
  
20
  Control getActiveControl();
20
  Control getActiveControl();
21
  
22
  void setActiveControl( Control control );
21
  void setActiveControl( Control control );
23
  
22
  
24
  Rectangle getMenuBounds();
23
  Rectangle getMenuBounds();
24
  
25
  void setBounds( Rectangle bounds );
25
}
26
}
(-)src/org/eclipse/swt/widgets/Shell.java (-4 / +15 lines)
Lines 128-140 Link Here
128
128
129
  private Control lastActive;
129
  private Control lastActive;
130
  private IShellAdapter shellAdapter;
130
  private IShellAdapter shellAdapter;
131
  private String text = "";
131
  private String text;
132
  private Image image;
132
  private Image image;
133
  private int alpha = 0xFF;
133
  private int alpha;
134
  private Button defaultButton;
134
  private Button defaultButton;
135
  private Button saveDefault;
135
  private Button saveDefault;
136
  private Control savedFocus;  // TODO [rh] move to Decorations when exist
136
  private Control savedFocus;  // TODO [rh] move to Decorations when exist
137
  private int mode = MODE_NONE;
137
  private int mode;
138
138
139
  private Shell( final Display display,
139
  private Shell( final Display display,
140
                 final Shell parent,
140
                 final Shell parent,
Lines 147-152 Link Here
147
    } else {
147
    } else {
148
      this.display = Display.getCurrent();
148
      this.display = Display.getCurrent();
149
    }
149
    }
150
    text = "";
151
    alpha = 0xFF;
152
    mode = MODE_NONE;
150
    this.style = checkStyle( style );
153
    this.style = checkStyle( style );
151
    state |= HIDDEN;
154
    state |= HIDDEN;
152
    this.display.addShell( this );
155
    this.display.addShell( this );
Lines 527-532 Link Here
527
  Composite findDeferredControl() {
530
  Composite findDeferredControl() {
528
    return layoutCount > 0 ? this : null;
531
    return layoutCount > 0 ? this : null;
529
  }
532
  }
533
  
534
  void updateMode() {
535
    mode &= ~MODE_MAXIMIZED;
536
    mode &= ~MODE_MINIMIZED;
537
  }
530
538
531
  /////////////////////
539
  /////////////////////
532
  // Adaptable override
540
  // Adaptable override
Lines 545-550 Link Here
545
          public Rectangle getMenuBounds() {
553
          public Rectangle getMenuBounds() {
546
            return Shell.this.getMenuBounds();
554
            return Shell.this.getMenuBounds();
547
          }
555
          }
556
          public void setBounds( final Rectangle bounds ) {
557
            Shell.this.setBounds( bounds, false );
558
          }
548
        };
559
        };
549
      }
560
      }
550
      result = shellAdapter;
561
      result = shellAdapter;
Lines 1158-1164 Link Here
1158
   * @see #setMaximized
1169
   * @see #setMaximized
1159
   */
1170
   */
1160
  public boolean getMaximized() {
1171
  public boolean getMaximized() {
1161
    return this.mode == MODE_MAXIMIZED;
1172
    return mode == MODE_MAXIMIZED;
1162
  }
1173
  }
1163
1174
1164
  ///////////////////
1175
  ///////////////////
(-)src/org/eclipse/swt/widgets/Control.java (-10 / +21 lines)
Lines 799-812 Link Here
799
    if( bounds == null ) {
799
    if( bounds == null ) {
800
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
800
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
801
    }
801
    }
802
    Point oldLocation = getLocation();
802
    setBounds( bounds, true );
803
    Point oldSize = getSize();
804
    this.bounds
805
      = new Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
806
    this.bounds.width = Math.max( 0, this.bounds.width );
807
    this.bounds.height = Math.max( 0, this.bounds.height );
808
    notifyMove( oldLocation );
809
    notifyResize( oldSize );
810
  }
803
  }
811
804
812
  /**
805
  /**
Lines 1785-1792 Link Here
1785
    return result;
1778
    return result;
1786
  }
1779
  }
1787
1780
1788
  //////////////////////////////////////////////////////
1781
  ////////////////////////////////
1789
  // Helping methods that throw move- and resize-events
1782
  // Helping methods for setBounds
1783
1784
  void setBounds( final Rectangle bounds, boolean updateMode ) {
1785
    Point oldLocation = getLocation();
1786
    Point oldSize = getSize();
1787
    this.bounds
1788
      = new Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
1789
    this.bounds.width = Math.max( 0, this.bounds.width );
1790
    this.bounds.height = Math.max( 0, this.bounds.height );
1791
    if( updateMode ) {
1792
      updateMode();
1793
    }
1794
    notifyMove( oldLocation );
1795
    notifyResize( oldSize );
1796
  }
1797
1798
  void updateMode() {
1799
    // subclasses may override
1800
  }
1790
1801
1791
  void notifyResize( final Point oldSize ) {
1802
  void notifyResize( final Point oldSize ) {
1792
    if( !oldSize.equals( getSize() ) ) {
1803
    if( !oldSize.equals( getSize() ) ) {
(-)src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java (-1 / +3 lines)
Lines 329-335 Link Here
329
329
330
    for( int i = 0; i < shells.length; i++ ) {
330
    for( int i = 0; i < shells.length; i++ ) {
331
      if( shells[ i ].getMaximized() ) {
331
      if( shells[ i ].getMaximized() ) {
332
        shells[ i ].setBounds( display.getBounds() );
332
        Object adapter = shells[ i ].getAdapter( IShellAdapter.class );
333
        IShellAdapter shellAdapter = ( IShellAdapter )adapter;
334
        shellAdapter.setBounds( display.getBounds() );
333
      }
335
      }
334
    }
336
    }
335
  }
337
  }
(-)src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java (-1 / +8 lines)
Lines 64-70 Link Here
64
    Shell shell = ( Shell )widget;
64
    Shell shell = ( Shell )widget;
65
    // [if] Preserve the menu bounds before setting the new shell bounds.
65
    // [if] Preserve the menu bounds before setting the new shell bounds.
66
    preserveMenuBounds( shell );
66
    preserveMenuBounds( shell );
67
    ControlLCAUtil.readBounds( shell );
67
    readBounds( shell );
68
    readMode( shell );
68
    readMode( shell );
69
    if( WidgetLCAUtil.wasEventSent( shell, JSConst.EVENT_SHELL_CLOSED ) ) {
69
    if( WidgetLCAUtil.wasEventSent( shell, JSConst.EVENT_SHELL_CLOSED ) ) {
70
      shell.close();
70
      shell.close();
Lines 291-296 Link Here
291
  //////////////////
291
  //////////////////
292
  // Helping methods
292
  // Helping methods
293
293
294
  private static void readBounds( final Shell shell ) {
295
    Rectangle bounds = WidgetLCAUtil.readBounds( shell, shell.getBounds() );
296
    Object adapter = shell.getAdapter( IShellAdapter.class );
297
    IShellAdapter shellAdapter = ( IShellAdapter )adapter;
298
    shellAdapter.setBounds( bounds );
299
  }
300
294
  private static void readMode( final Shell shell ) {
301
  private static void readMode( final Shell shell ) {
295
    final String value = WidgetLCAUtil.readPropertyValue( shell, "mode" );
302
    final String value = WidgetLCAUtil.readPropertyValue( shell, "mode" );
296
    if( value != null ) {
303
    if( value != null ) {
(-)src/org/eclipse/swt/widgets/Shell_Test.java (-2 / +77 lines)
Lines 18-25 Link Here
18
import org.eclipse.rwt.lifecycle.PhaseId;
18
import org.eclipse.rwt.lifecycle.PhaseId;
19
import org.eclipse.swt.RWTFixture;
19
import org.eclipse.swt.RWTFixture;
20
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.ShellAdapter;
21
import org.eclipse.swt.events.*;
22
import org.eclipse.swt.events.ShellEvent;
23
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.internal.widgets.IShellAdapter;
24
import org.eclipse.swt.internal.widgets.IShellAdapter;
Lines 366-371 Link Here
366
    assertEquals( shell.getBounds(), display.getBounds() );
365
    assertEquals( shell.getBounds(), display.getBounds() );
367
  }
366
  }
368
367
368
  public void testSetBoundsResetMaximized() {
369
    Display display = new Display();
370
    Shell shell = new Shell( display );
371
    shell.setBounds( 1, 2, 3, 4 );
372
    shell.setMaximized( true );
373
    Rectangle bounds = new Rectangle( 10, 10, 10, 10 );
374
    shell.setBounds( bounds );
375
    assertFalse( shell.getMaximized() );
376
    assertEquals( bounds, shell.getBounds() );
377
  }
378
379
  public void testSetLocationResetMaximized() {
380
    Display display = new Display();
381
    Shell shell = new Shell( display );
382
    shell.setBounds( 1, 2, 3, 4 );
383
    shell.setMaximized( true );
384
    shell.setLocation( 10, 10 );
385
    assertFalse( shell.getMaximized() );
386
  }
387
388
  public void testSetSizeResetMaximized() {
389
    Display display = new Display();
390
    Shell shell = new Shell( display );
391
    shell.setBounds( 1, 2, 3, 4 );
392
    shell.setMaximized( true );
393
    shell.setSize( 6, 6 );
394
    assertFalse( shell.getMaximized() );
395
  }
396
397
  public void testSetBoundsResetMaximizedEventOrder() {
398
    final boolean[] maximized = {
399
      true
400
    };
401
    Display display = new Display();
402
    final Shell shell = new Shell( display );
403
    shell.setBounds( 1, 2, 3, 4 );
404
    shell.addControlListener( new ControlAdapter() {
405
      public void controlResized( final ControlEvent event ) {
406
        maximized[ 0 ] = shell.getMaximized();
407
      }
408
    } );
409
    shell.setMaximized( true );
410
    shell.setSize( 6, 6 );
411
    assertFalse( maximized[ 0 ] );
412
  }
413
414
  public void testShellAdapterSetBounds() {
415
    final java.util.List log = new ArrayList();
416
    Display display = new Display();
417
    Shell shell = new Shell( display );
418
    shell.setBounds( 1, 2, 3, 4 );
419
    shell.setMaximized( true );
420
    shell.addControlListener( new ControlAdapter() {
421
      public void controlResized( final ControlEvent event ) {
422
        log.add( event );
423
      }
424
    } );
425
    Object adapter = shell.getAdapter( IShellAdapter.class );
426
    IShellAdapter shellAdapter = ( IShellAdapter )adapter;
427
    shellAdapter.setBounds( new Rectangle( 5, 6, 7, 8 ) );
428
    assertEquals( new Rectangle( 5, 6, 7, 8 ), shell.getBounds() );
429
    assertTrue( shell.getMaximized() );
430
    assertEquals( 1, log.size() );
431
  }
432
433
  public void testSetBoundsResetMinimized() {
434
    Display display = new Display();
435
    Shell shell = new Shell( display );
436
    shell.setBounds( 1, 2, 3, 4 );
437
    shell.setMinimized( true );
438
    Rectangle bounds = new Rectangle( 10, 10, 10, 10 );
439
    shell.setBounds( bounds );
440
    assertFalse( shell.getMinimized() );
441
    assertEquals( bounds, shell.getBounds() );
442
  }
443
369
  protected void setUp() throws Exception {
444
  protected void setUp() throws Exception {
370
    RWTFixture.setUp();
445
    RWTFixture.setUp();
371
    RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
446
    RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );

Return to bug 278195