23.12.2014 Views

NASA uses Eclipse RCP applications for experiments on the ...

NASA uses Eclipse RCP applications for experiments on the ...

NASA uses Eclipse RCP applications for experiments on the ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How to fake butt<strong>on</strong>s <br />

ISS standards require us to create unique rounded “command” butt<strong>on</strong>s, so it is<br />

clear which butt<strong>on</strong>s send important commands. These butt<strong>on</strong>s draw images to<br />

a graphics c<strong>on</strong>text, and <strong>the</strong>n render text over <strong>the</strong>m. <br />

public class CommandButt<strong>on</strong> extends Composite {!<br />

!<br />

public CommandButt<strong>on</strong>(Composite parent, int style) {!<br />

!<br />

!super(parent, SWT.NONE);!<br />

!GridLayout gl = new GridLayout(1, false);!<br />

!gl.marginHeight = gl.marginWidth = gl.horiz<strong>on</strong>talSpacing = gl.verticalSpacing = 0;!<br />

!setLayout(gl);!<br />

!m_gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);!<br />

!m_gridData.widthHint = m_gridData.minimumWidth = m_width;!<br />

!m_gridData.heightHint = m_gridData.minimumHeight = m_height;!<br />

!setLayoutData(m_gridData);!<br />

!setSize(m_width, m_height);!<br />

!<br />

!m_butt<strong>on</strong>Label = new Canvas(this, SWT.NONE);!<br />

!m_butt<strong>on</strong>Label.setSize(m_width, m_height);!<br />

!m_butt<strong>on</strong>Label.setLayoutData(m_gridData);!<br />

!m_butt<strong>on</strong>Label.addPaintListener(new PaintListener() {!<br />

! !public void paintC<strong>on</strong>trol(PaintEvent e) { draw(e.gc); }!<br />

!});!<br />

! !!<br />

! !!<br />

Enabled Pressed Disabled <br />

<str<strong>on</strong>g>Eclipse</str<strong>on</strong>g> <str<strong>on</strong>g>RCP</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> ISS Experiments <br />

24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!