Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327539

Summary: [Scrollable] getClientArea reports negative dimension
Product: [RT] RAP Reporter: Tim Buschtoens <tbuschto>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 1.4   
Target Milestone: 1.4 M3   
Hardware: All   
OS: All   
Whiteboard:

Description Tim Buschtoens CLA 2010-10-12 07:08:59 EDT
Scrollable#getClientArea will report negative dimensions if the sum of border, padding and Scrollbar is larger than the actual outer dimension.

Test:
  public void testClientAreaIsZero() {
    Display display = new Display();
    Composite shell = new Shell( display, SWT.NONE );
    Composite composite = new Composite( shell, SWT.BORDER );
    composite.setSize( 0, 0 );
    assertEquals( 2, composite.getBorderWidth() );
    Rectangle expected = new Rectangle( 0, 0, 0, 0 );
    assertEquals( expected, composite.getClientArea() );
    composite = new Composite( shell, SWT.BORDER ) {
      int getVScrollBarWidth() {
        return 20;
      }
      int getHScrollBarHeight() {
        return 20;
      }
      Rectangle getPadding() {
        return new Rectangle( 0, 0, 10, 10 );
      }
    };
    composite.setSize( 25, 25 );
    assertEquals( 2, composite.getBorderWidth() );
    expected = new Rectangle( 10, 10, 0, 0 );
    assertEquals( expected, composite.getClientArea() );
  }
Comment 1 Tim Buschtoens CLA 2010-10-12 07:12:24 EDT
Small mistake in the code. It should be :

  Rectangle getPadding() {
    return new Rectangle( 10, 10, 10, 10 );
  }
Comment 2 Tim Buschtoens CLA 2010-10-12 07:24:52 EDT
Fixed in CVS HEAD