1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-12 19:45:22 +02:00

Bug 158301 - adding back drawn control support for windows platforms

This commit is contained in:
David Dykstal 2006-11-02 17:02:28 +00:00
parent 1c12d002b3
commit 593a240622
2 changed files with 83 additions and 72 deletions

View file

@ -56,17 +56,18 @@ public class InheritButton extends Composite {
/** /**
* Value is 12 pixels. * Value is 12 pixels.
*/ */
// public static final int DEFAULT_WIDTH = 40; public static final int DEFAULT_WIDTH = 12;
/** /**
* Value is 20 pixels. * Value is 20 pixels.
*/ */
// public static final int DEFAULT_HEIGHT = 35; public static final int DEFAULT_HEIGHT = 20;
// private Image leftArrow = null; // arrow points left, value is inherited private Image leftArrow = null; // arrow points left, value is inherited
// private Image rightArrow = null; // arrow points right, value is the local value private Image rightArrow = null; // arrow points right, value is the local value
private boolean isLocal = false; // default is "inherit" private boolean isLocal = false; // default is "inherit"
private Button toggle = null; private Button toggle = null;
private boolean isDrawn = false; // button is to be drawn or use arrow implementation
/** /**
* Create a new InheritButton. * Create a new InheritButton.
@ -74,10 +75,13 @@ public class InheritButton extends Composite {
*/ */
public InheritButton(Composite parent) { public InheritButton(Composite parent) {
super(parent, SWT.NONE); super(parent, SWT.NONE);
// GridData data = new GridData(SWT.CENTER, SWT.CENTER, false, false); isDrawn = System.getProperty("os.name").toLowerCase().startsWith("win");
// data.widthHint = DEFAULT_WIDTH; if (isDrawn) {
// data.heightHint = DEFAULT_HEIGHT; GridData data = new GridData(SWT.CENTER, SWT.CENTER, false, false);
// setLayoutData(data); data.widthHint = DEFAULT_WIDTH;
data.heightHint = DEFAULT_HEIGHT;
setLayoutData(data);
}
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.marginHeight = 0; layout.marginHeight = 0;
layout.marginWidth = 0; layout.marginWidth = 0;
@ -86,9 +90,17 @@ public class InheritButton extends Composite {
} }
private void initializeToggle(Composite parent) { private void initializeToggle(Composite parent) {
// toggle = new Button(parent, SWT.PUSH ); if (isDrawn) {
toggle = new Button(parent, SWT.ARROW ); toggle = new Button(parent, SWT.PUSH );
// createToggleImages(toggle.getBackground()); createToggleImages(toggle.getBackground());
toggle.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
disposeToggleImages();
}
});
} else {
toggle = new Button(parent, SWT.ARROW );
}
toggle.getAccessible().addAccessibleListener(new AccessibleAdapter() { toggle.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getHelp(AccessibleEvent e) { // this is the one that should supply the text heard. public void getHelp(AccessibleEvent e) { // this is the one that should supply the text heard.
e.result = ""; e.result = "";
@ -109,11 +121,6 @@ public class InheritButton extends Composite {
} }
} }
}); });
// toggle.addDisposeListener(new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// disposeToggleImages();
// }
// });
toggle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); toggle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
setToggleImage(); setToggleImage();
} }
@ -208,9 +215,12 @@ public class InheritButton extends Composite {
* In the "inherit" state, the arrow image points to the left. * In the "inherit" state, the arrow image points to the left.
*/ */
private void setToggleImage() { private void setToggleImage() {
// toggle.setImage(isLocal ? rightArrow : leftArrow); if (isDrawn) {
int alignment = isLocal ? SWT.RIGHT : SWT.LEFT; toggle.setImage(isLocal ? rightArrow : leftArrow);
toggle.setAlignment(alignment); } else {
int alignment = isLocal ? SWT.RIGHT : SWT.LEFT;
toggle.setAlignment(alignment);
}
} }
/** /**
@ -219,38 +229,38 @@ public class InheritButton extends Composite {
* @param backgroundColor The background color with which the arrow images * @param backgroundColor The background color with which the arrow images
* should be painted. The foreground color is black. * should be painted. The foreground color is black.
*/ */
// private void createToggleImages(Color backgroundColor) { private void createToggleImages(Color backgroundColor) {
// Display display = Display.getCurrent(); Display display = Display.getCurrent();
// GC gc = null; GC gc = null;
// if (display != null) { if (display != null) {
// leftArrow = new Image(display, 3, 5); leftArrow = new Image(display, 3, 5);
// gc = new GC(leftArrow); gc = new GC(leftArrow);
// gc.setBackground(backgroundColor); gc.setBackground(backgroundColor);
// gc.fillRectangle(leftArrow.getBounds()); gc.fillRectangle(leftArrow.getBounds());
// gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
// gc.drawLine(0, 2, 0, 2); gc.drawLine(0, 2, 0, 2);
// gc.drawLine(1, 1, 1, 3); gc.drawLine(1, 1, 1, 3);
// gc.drawLine(2, 0, 2, 4); gc.drawLine(2, 0, 2, 4);
// gc.dispose(); gc.dispose();
// rightArrow = new Image(display, 3, 5); rightArrow = new Image(display, 3, 5);
// gc = new GC(rightArrow); gc = new GC(rightArrow);
// gc.setBackground(backgroundColor); gc.setBackground(backgroundColor);
// gc.fillRectangle(rightArrow.getBounds()); gc.fillRectangle(rightArrow.getBounds());
// gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
// gc.drawLine(0, 0, 0, 4); gc.drawLine(0, 0, 0, 4);
// gc.drawLine(1, 1, 1, 3); gc.drawLine(1, 1, 1, 3);
// gc.drawLine(2, 2, 2, 2); gc.drawLine(2, 2, 2, 2);
// gc.dispose(); gc.dispose();
// } }
// } }
/** /**
* Dispose of the images used for the arrow graphics. Should be invoked * Dispose of the images used for the arrow graphics. Should be invoked
* when the button is disposed. * when the button is disposed.
*/ */
// private void disposeToggleImages() { private void disposeToggleImages() {
// if (leftArrow != null) leftArrow.dispose(); if (leftArrow != null) leftArrow.dispose();
// if (rightArrow != null) rightArrow.dispose(); if (rightArrow != null) rightArrow.dispose();
// } }
} }

View file

@ -613,31 +613,32 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave
scheme used an SWT.ARROW button style which was not tab enabled and could not provide a focus rectangle. scheme used an SWT.ARROW button style which was not tab enabled and could not provide a focus rectangle.
Changes: made the control a push button, programmatically drew the arrow on the button, and provided accessibility information. Changes: made the control a push button, programmatically drew the arrow on the button, and provided accessibility information.
*/ */
/* boolean isDrawn = System.getProperty("os.name").toLowerCase().startsWith("win");
* dwd: as of eclipse 3.2 it now appears the arrow buttons are accessible, reverting to previous implementation. if (isDrawn) {
*/ historyButton = new Button(this, SWT.PUSH);
historyButton = new Button(this, SWT.ARROW); Display display = this.getDisplay();
historyButton.setAlignment(SWT.UP); final Image upArrow = new Image(display, 5, 6);
// historyButton = new Button(this, SWT.PUSH); GC gc = new GC(upArrow);
// Display display = this.getDisplay(); gc.setBackground(historyButton.getBackground());
// final Image upArrow = new Image(display, 5, 6); gc.fillRectangle(upArrow.getBounds());
// GC gc = new GC(upArrow); gc.setForeground(historyButton.getForeground());
// gc.setBackground(historyButton.getBackground()); gc.drawLine(0, 5, 4, 5);
// gc.fillRectangle(upArrow.getBounds()); gc.drawLine(0, 4, 4, 4);
// gc.setForeground(historyButton.getForeground()); gc.drawLine(1, 3, 3, 3);
// gc.drawLine(0, 5, 4, 5); gc.drawLine(1, 2, 3, 2);
// gc.drawLine(0, 4, 4, 4); gc.drawLine(2, 1, 2, 1);
// gc.drawLine(1, 3, 3, 3); gc.drawLine(2, 0, 2, 0);
// gc.drawLine(1, 2, 3, 2); gc.dispose();
// gc.drawLine(2, 1, 2, 1); historyButton.addDisposeListener(new DisposeListener() {
// gc.drawLine(2, 0, 2, 0); public void widgetDisposed(DisposeEvent e) {
// gc.dispose(); upArrow.dispose();
// historyButton.addDisposeListener(new DisposeListener() { }
// public void widgetDisposed(DisposeEvent e) { });
// upArrow.dispose(); historyButton.setImage(upArrow);
// } } else {
// }); historyButton = new Button(this, SWT.ARROW);
// historyButton.setImage(upArrow); historyButton.setAlignment(SWT.UP);
}
historyButton.setToolTipText(SystemResources.RESID_WORKWITHHISTORY_BUTTON_TIP); historyButton.setToolTipText(SystemResources.RESID_WORKWITHHISTORY_BUTTON_TIP);
historyButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { historyButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getHelp(AccessibleEvent e) { // this is the one that should supply the text heard. public void getHelp(AccessibleEvent e) { // this is the one that should supply the text heard.