Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327539 - [Scrollable] getClientArea reports negative dimension
Summary: [Scrollable] getClientArea reports negative dimension
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.4 M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-12 07:08 EDT by Tim Buschtoens CLA
Modified: 2010-10-12 07:24 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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