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

(-)src/org/eclipse/swt/widgets/ToolItem.java (-12 / +19 lines)
Lines 38-44 Link Here
38
38
39
  private static final int DEFAULT_WIDTH = 24;
39
  private static final int DEFAULT_WIDTH = 24;
40
  private static final int DEFAULT_HEIGHT = 22;
40
  private static final int DEFAULT_HEIGHT = 22;
41
  private static final int DROP_DOWN_ARROW_WIDTH = 13;
41
  // TODO [rst] Read these values from ThemeAdapter as soon as ToolItem is
42
  //            themeable
43
  private static final int DROP_DOWN_ARROW_WIDTH = 15;
44
  private static final int SEPARATOR_WIDTH = 8;
45
  private static final int SPACING = 4;
46
  private static final int PADDING_WIDTH = 6;
47
  private static final int BORDER_WIDTH = 2;
42
48
43
  private final ToolBar parent;
49
  private final ToolBar parent;
44
  private boolean selected;
50
  private boolean selected;
Lines 408-429 Link Here
408
    if( ( style & SWT.SEPARATOR ) != 0 ) {
414
    if( ( style & SWT.SEPARATOR ) != 0 ) {
409
      result = width;
415
      result = width;
410
    } else {
416
    } else {
411
      // TODO [rh] must be kept in sync with DefaultAppearanceTheme.js
417
      result = 0;
412
      result = 7; // approx left + right padding as defined in appearance theme 
418
      boolean hasImage = image != null;
413
      if( getImage() != null ) {
419
      boolean hasText = !"".equals( text );
414
        result += getImage().getBounds().width;
420
      if( hasImage ) {
421
        result += image.getBounds().width;
415
      }
422
      }
416
      String text = getText();
423
      if( hasText ) {
417
      if( !"".equals( text ) ) {
418
        Font font = parent.getFont();
424
        Font font = parent.getFont();
419
        // TODO [fappel]: need some more space for the Workbench perspective
425
        result += TextSizeDetermination.stringExtent( font, text ).x;
420
        //                switcher. Check this after a proper font size
426
      }
421
        //                calculation is in place
427
      if( hasText && hasImage ) {
422
        result += 11 + TextSizeDetermination.stringExtent( font, getText() ).x;
428
        result += SPACING;
423
      }
429
      }
424
      if( ( style & SWT.DROP_DOWN ) != 0 ) {
430
      if( ( style & SWT.DROP_DOWN ) != 0 ) {
425
        result += DROP_DOWN_ARROW_WIDTH;
431
        result += DROP_DOWN_ARROW_WIDTH;
426
      }
432
      }
433
      result += PADDING_WIDTH + BORDER_WIDTH;
427
    }
434
    }
428
    return result;
435
    return result;
429
  }
436
  }
Lines 594-600 Link Here
594
601
595
  private void computeInitialWidth() {
602
  private void computeInitialWidth() {
596
    if( ( style & SWT.SEPARATOR ) != 0 ) {
603
    if( ( style & SWT.SEPARATOR ) != 0 ) {
597
      width = 8;
604
      width = SEPARATOR_WIDTH;
598
    } else {
605
    } else {
599
      width = DEFAULT_WIDTH;
606
      width = DEFAULT_WIDTH;
600
      if( ( style & SWT.DROP_DOWN ) != 0 ) {
607
      if( ( style & SWT.DROP_DOWN ) != 0 ) {

Return to bug 234037