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 419441
Collapse All | Expand All

(-)a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Button.java (-9 / +22 lines)
Lines 379-393 Link Here
379
    int height = 0;
379
    int height = 0;
380
    boolean hasImage = image != null;
380
    boolean hasImage = image != null;
381
    boolean hasText = text.length() > 0;
381
    boolean hasText = text.length() > 0;
382
    if( hasImage ) {
382
    ButtonThemeAdapter themeAdapter = ( ButtonThemeAdapter )getAdapter( IThemeAdapter.class );
383
    Rectangle padding = themeAdapter.getPadding( this );
384
     if( hasImage ) {
383
      Rectangle imageBounds = image.getBounds ();
385
      Rectangle imageBounds = image.getBounds ();
384
      width = imageBounds.width;
386
      width = imageBounds.width;
385
      height = imageBounds.height;
387
      height = imageBounds.height;
386
    }
388
    }
389
    if( hasText && hasImage ) {
390
      int spacing = themeAdapter.getSpacing( this );
391
      width += spacing;
392
    }
387
    if( hasText ) {
393
    if( hasText ) {
388
      Point extent;
394
      Point extent;
389
      if( ( style & SWT.WRAP ) != 0 ) {
395
      if( ( style & SWT.WRAP ) != 0 ) {
390
        extent = TextSizeUtil.textExtent( getFont(), text, wHint );
396
        int wrapWidth = wHint;
397
        if (wHint != SWT.DEFAULT) {
398
          // Width is constrained so compute width remaining for text when all other button elements are displayed
399
          int checkOrRadioWidth = 0;
400
          if( ( style & ( SWT.CHECK | SWT.RADIO ) ) != 0 ) {
401
            Point checkSize = themeAdapter.getCheckSize( this );
402
            checkOrRadioWidth = checkSize.x;
403
            if( hasText || hasImage ) {
404
              checkOrRadioWidth += themeAdapter.getCheckSpacing( this );
405
            }
406
           }
407
          wrapWidth = wHint - (width + checkOrRadioWidth + padding.width);
408
        }
409
        extent = TextSizeUtil.textExtent( getFont(), text, wrapWidth );
391
      } else {
410
      } else {
392
        extent = TextSizeUtil.stringExtent( getFont(), text );
411
        extent = TextSizeUtil.stringExtent( getFont(), text );
393
      }
412
      }
Lines 396-407 Link Here
396
    }
415
    }
397
    if( height == 0 ) {
416
    if( height == 0 ) {
398
      height = 10;
417
      height = 10;
399
    }
418
    }   
400
    ButtonThemeAdapter themeAdapter = ( ButtonThemeAdapter )getAdapter( IThemeAdapter.class );
401
    if( hasText && hasImage ) {
402
      int spacing = themeAdapter.getSpacing( this );
403
      width += spacing;
404
    }
405
    if( ( style & ( SWT.CHECK | SWT.RADIO ) ) != 0 ) {
419
    if( ( style & ( SWT.CHECK | SWT.RADIO ) ) != 0 ) {
406
      Point checkSize = themeAdapter.getCheckSize( this );
420
      Point checkSize = themeAdapter.getCheckSize( this );
407
      width += checkSize.x;
421
      width += checkSize.x;
Lines 413-419 Link Here
413
      width = themeAdapter.getArrowSize( this ).x;
427
      width = themeAdapter.getArrowSize( this ).x;
414
      height = themeAdapter.getArrowSize( this ).y;
428
      height = themeAdapter.getArrowSize( this ).y;
415
    }
429
    }
416
    Rectangle padding = themeAdapter.getPadding( this );
417
    width += padding.width;
430
    width += padding.width;
418
    height += padding.height;
431
    height += padding.height;
419
    if( wHint != SWT.DEFAULT ) {
432
    if( wHint != SWT.DEFAULT ) {

Return to bug 419441