Fixed Styling and window system resource handling
This commit is contained in:
@ -14,24 +14,27 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.wb.swt.SWTResourceManager;
|
||||
|
||||
public class RulerPainter implements IPainter {
|
||||
protected WaveformCanvas waveCanvas;
|
||||
|
||||
static final int rulerTickMinorC = 10;
|
||||
static final int rulerTickMajorC = 100;
|
||||
|
||||
private Color headerBgColor;
|
||||
private Color headerFgColor;
|
||||
|
||||
public RulerPainter(WaveformCanvas waveCanvas, Color headerFgColor, Color headerBgColor) {
|
||||
|
||||
public RulerPainter(WaveformCanvas waveCanvas) {
|
||||
this.waveCanvas=waveCanvas;
|
||||
this.headerBgColor=headerBgColor;
|
||||
this.headerFgColor=headerFgColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintArea(GC gc, Rectangle area) {
|
||||
Color headerFgColor=waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
|
||||
if(headerFgColor.isDisposed())
|
||||
headerFgColor=SWTResourceManager.getColor(0,0,0);
|
||||
Color headerBgColor = waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
|
||||
if(headerBgColor.isDisposed())
|
||||
headerBgColor=SWTResourceManager.getColor(255,255,255);
|
||||
String unit=waveCanvas.getUnitStr();
|
||||
int unitMultiplier=waveCanvas.getUnitMultiplier();
|
||||
long scaleFactor=waveCanvas.getScaleFactor();
|
||||
|
@ -111,7 +111,7 @@ public class WaveformCanvas extends Canvas {
|
||||
// order is important: it is bottom to top
|
||||
trackAreaPainter=new TrackAreaPainter(this);
|
||||
painterList.add(trackAreaPainter);
|
||||
rulerPainter=new RulerPainter(this, getDisplay().getSystemColor(SWT.COLOR_BLACK), getDisplay().getSystemColor(SWT.COLOR_WHITE));
|
||||
rulerPainter=new RulerPainter(this);
|
||||
painterList.add(rulerPainter);
|
||||
CursorPainter cp = new CursorPainter(this, scaleFactor * 10, cursorPainters.size()-1);
|
||||
painterList.add(cp);
|
||||
|
@ -96,6 +96,8 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
|
||||
private ScrolledComposite valueListScrolled;
|
||||
|
||||
private Control namePaneHeader;
|
||||
|
||||
private Canvas nameList;
|
||||
|
||||
private Canvas valueList;
|
||||
@ -239,10 +241,11 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
waveformCanvas = new WaveformCanvas(topSash, SWT.NONE);
|
||||
|
||||
SashForm leftSash = new SashForm(composite, SWT.SMOOTH);
|
||||
leftSash.setBackground(leftSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
|
||||
leftSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
|
||||
|
||||
Composite namePane = createTextPane(leftSash, "Name");
|
||||
namePane.setBackground(namePane.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
namePaneHeader= namePane.getChildren()[0];
|
||||
namePane.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
|
||||
nameListScrolled = new ScrolledComposite(namePane, SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
nameListScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
||||
@ -275,7 +278,7 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
nameListScrolled.setContent(nameList);
|
||||
|
||||
Composite valuePane = createTextPane(leftSash, "Value");
|
||||
valuePane.setBackground(valuePane.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
valuePane.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
valueListScrolled = new ScrolledComposite(valuePane, SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
valueListScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
||||
valueListScrolled.setExpandHorizontal(true);
|
||||
@ -805,8 +808,8 @@ public class WaveformViewer implements IWaveformViewer {
|
||||
gc.fillRectangle(subArea.x, subArea.y + yOffset, subArea.width, subArea.height);
|
||||
gc.setFont(nameFontB);
|
||||
} else {
|
||||
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_BACKGROUND));
|
||||
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_FOREGROUND));
|
||||
gc.setBackground(namePaneHeader.getBackground());
|
||||
gc.setForeground(namePaneHeader.getForeground());
|
||||
gc.setFont(nameFont);
|
||||
}
|
||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (waveformCanvas.getTrackHeight() - size.y) / 2, true);
|
||||
|
Reference in New Issue
Block a user