diff options
author | Jeff Brown <jbrown> | 2001-06-22 20:21:19 +0000 |
---|---|---|
committer | Jeff Brown <jbrown> | 2001-06-22 20:21:19 +0000 |
commit | 3dab7e95b84ef38f6c138ded1cdaa1b3e783a9cf (patch) | |
tree | 8a3560c510e690157e2a953e507ae80d04d25f7f | |
parent | f4d33caae0903ec665eae1ff75ac093d9ac6e3a1 (diff) | |
download | eclipse.platform.swt-3dab7e95b84ef38f6c138ded1cdaa1b3e783a9cf.tar.gz eclipse.platform.swt-3dab7e95b84ef38f6c138ded1cdaa1b3e783a9cf.tar.xz eclipse.platform.swt-3dab7e95b84ef38f6c138ded1cdaa1b3e783a9cf.zip |
*** empty log message ***
5 files changed, 7 insertions, 7 deletions
diff --git a/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PaintSurface.java b/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PaintSurface.java index 0a179abdef..5cd1827e42 100755 --- a/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PaintSurface.java +++ b/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PaintSurface.java @@ -7,7 +7,7 @@ package org.eclipse.swt.examples.paint;
/**
* Manages a simple drawing surface.
*/
public class PaintSurface {
private Point currentPosition = new Point(0, 0);
private Canvas paintCanvas;
private PaintSession paintSession;
private Image image;
private Image paintImage; // buffer for refresh blits
private int imageWidth, imageHeight;
private int visibleWidth, visibleHeight;
private FigureDrawContext displayFDC = new FigureDrawContext();
private FigureDrawContext imageFDC = new FigureDrawContext();
private FigureDrawContext paintFDC = new FigureDrawContext();
/* Rubberband */
private ContainerFigure rubberband = new ContainerFigure();
// the active rubberband selection
private int rubberbandHiddenNestingCount = 0;
// always >= 0, if > 0 rubberband has been hidden
/* Status */
private Text statusText;
private String statusActionInfo, statusMessageInfo, statusCoordInfo;
/**
* Constructs a PaintSurface.
* <p>
* paintCanvas must have SWT.NO_REDRAW_RESIZE and SWT.NO_BACKGROUND styles,
* and may have SWT.V_SCROLL and/or SWT.H_SCROLL.
* </p>
* @param paintCanvas the Canvas object in which to render
* @param paintStatus the PaintStatus object to use for providing user feedback
* @param fillColor the color to fill the canvas with initially
*/
- public PaintSurface(Canvas paintCanvas, Text statusText, Color fillColor) {
this.paintCanvas = paintCanvas;
this.statusText = statusText;
clearStatus();
/* Set up the drawing surface */
Rectangle displayRect = paintCanvas.getDisplay().getClientArea();
imageWidth = displayRect.width;
imageHeight = displayRect.height;
image = new Image(paintCanvas.getDisplay(), imageWidth, imageHeight);
imageFDC.gc = new GC(image);
imageFDC.gc.setBackground(fillColor);
imageFDC.gc.fillRectangle(0, 0, imageWidth, imageHeight);
displayFDC.gc = new GC(paintCanvas);
/* Initialize the session */
setPaintSession(null);
/* Add our listeners */
paintCanvas.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDown(event);
}
public void mouseUp(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseUp(event);
}
public void mouseDoubleClick(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDoubleClick(event);
}
});
paintCanvas.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseMove(event);
}
});
paintCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
if (rubberband.isEmpty()) {
event.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
} else {
// avoid flicker when merging overlayed objects
if (paintImage != null) {
Rectangle rect = paintImage.getBounds();
if ((event.width + event.x > rect.width) ||
(event.height + event.y > rect.height)) {
paintFDC.gc.dispose();
paintImage.dispose();
paintImage = null;
}
}
if (paintImage == null) {
Display display = getDisplay();
Rectangle rect = display.getClientArea();
paintImage = new Image(display,
Math.max(rect.width, event.width + event.x),
Math.max(rect.height, event.height + event.y));
paintFDC.gc = new GC(paintImage);
}
Region clipRegion = new Region();
event.gc.getClipping(clipRegion);
paintFDC.gc.setClipping(clipRegion);
clipRegion.dispose();
paintFDC.xOffset = displayFDC.xOffset;
paintFDC.yOffset = displayFDC.yOffset;
paintFDC.xScale = displayFDC.xScale;
paintFDC.yScale = displayFDC.yScale;
paintFDC.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
rubberband.draw(paintFDC);
event.gc.drawImage(paintImage,
event.x, event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
}
}
});
paintCanvas.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
handleResize();
}
});
/* Set up the paint canvas scroll bars */
ScrollBar horizontal = paintCanvas.getHorizontalBar();
horizontal.setVisible(true);
horizontal.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollHorizontally((ScrollBar)event.widget);
}
});
ScrollBar vertical = paintCanvas.getVerticalBar();
vertical.setVisible(true);
vertical.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollVertically((ScrollBar)event.widget);
}
});
handleResize();
}
/**
* Disposes of the PaintSurface's resources.
*/
public void dispose() {
imageFDC.gc.dispose();
displayFDC.gc.dispose();
image.dispose();
if (paintImage != null) {
paintImage.dispose();
paintFDC.gc.dispose();
}
currentPosition = null;
paintCanvas = null;
paintSession = null;
image = null;
paintImage = null;
displayFDC = null;
imageFDC = null;
paintFDC = null;
rubberband = null;
statusText = null;
statusActionInfo = null;
statusMessageInfo = null;
statusCoordInfo = null;
}
/**
* Called when we must grab focus.
*/
public void setFocus() {
paintCanvas.setFocus();
}
/**
* Returns the Display on which the PaintSurface resides.
* @return the Display
*/
public Display getDisplay() {
return paintCanvas.getDisplay();
}
/**
* Returns the Shell in which the PaintSurface resides.
* @return the Shell
*/
public Shell getShell() {
return paintCanvas.getShell();
}
/**
+ public PaintSurface(Canvas paintCanvas, Text statusText, Color fillColor) {
this.paintCanvas = paintCanvas;
this.statusText = statusText;
clearStatus();
/* Set up the drawing surface */
Rectangle displayRect = paintCanvas.getDisplay().getClientArea();
imageWidth = displayRect.width;
imageHeight = displayRect.height;
image = new Image(paintCanvas.getDisplay(), imageWidth, imageHeight);
imageFDC.gc = new GC(image);
imageFDC.gc.setBackground(fillColor);
imageFDC.gc.fillRectangle(0, 0, imageWidth, imageHeight);
displayFDC.gc = new GC(paintCanvas);
/* Initialize the session */
setPaintSession(null);
/* Add our listeners */
paintCanvas.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDown(event);
}
public void mouseUp(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseUp(event);
}
public void mouseDoubleClick(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDoubleClick(event);
}
});
paintCanvas.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseMove(event);
}
});
paintCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
if (rubberband.isEmpty()) {
// Nothing to merge, so we just refresh
event.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
} else {
/*
* Avoid flicker when merging overlayed objects by constructing the image on
* a backbuffer first, then blitting it to the screen.
*/
// Check that the backbuffer is large enough
if (paintImage != null) {
Rectangle rect = paintImage.getBounds();
if ((event.width + event.x > rect.width) ||
(event.height + event.y > rect.height)) {
paintFDC.gc.dispose();
paintImage.dispose();
paintImage = null;
}
}
if (paintImage == null) {
Display display = getDisplay();
Rectangle rect = display.getClientArea();
paintImage = new Image(display,
Math.max(rect.width, event.width + event.x),
Math.max(rect.height, event.height + event.y));
paintFDC.gc = new GC(paintImage);
}
// Setup clipping and the FDC
Region clipRegion = new Region();
event.gc.getClipping(clipRegion);
paintFDC.gc.setClipping(clipRegion);
clipRegion.dispose();
paintFDC.xOffset = displayFDC.xOffset;
paintFDC.yOffset = displayFDC.yOffset;
paintFDC.xScale = displayFDC.xScale;
paintFDC.yScale = displayFDC.yScale;
// Merge the overlayed objects into the image, then blit
paintFDC.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
rubberband.draw(paintFDC);
event.gc.drawImage(paintImage,
event.x, event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
}
}
});
paintCanvas.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
handleResize();
}
});
/* Set up the paint canvas scroll bars */
ScrollBar horizontal = paintCanvas.getHorizontalBar();
horizontal.setVisible(true);
horizontal.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollHorizontally((ScrollBar)event.widget);
}
});
ScrollBar vertical = paintCanvas.getVerticalBar();
vertical.setVisible(true);
vertical.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollVertically((ScrollBar)event.widget);
}
});
handleResize();
}
/**
* Disposes of the PaintSurface's resources.
*/
public void dispose() {
imageFDC.gc.dispose();
displayFDC.gc.dispose();
image.dispose();
if (paintImage != null) {
paintImage.dispose();
paintFDC.gc.dispose();
}
currentPosition = null;
paintCanvas = null;
paintSession = null;
image = null;
paintImage = null;
displayFDC = null;
imageFDC = null;
paintFDC = null;
rubberband = null;
statusText = null;
statusActionInfo = null;
statusMessageInfo = null;
statusCoordInfo = null;
}
/**
* Called when we must grab focus.
*/
public void setFocus() {
paintCanvas.setFocus();
}
/**
* Returns the Display on which the PaintSurface resides.
* @return the Display
*/
public Display getDisplay() {
return paintCanvas.getDisplay();
}
/**
* Returns the Shell in which the PaintSurface resides.
* @return the Shell
*/
public Shell getShell() {
return paintCanvas.getShell();
}
/**
* Sets the current paint session.
* <p>
* If oldPaintSession != paintSession calls oldPaintSession.end()
* and paintSession.begin()
* </p>
*
* @param paintSession the paint session to activate; null to disable all sessions
@@ -16,7 +16,7 @@ public class PaintSurface {
private Point currentPosition = new Point(0, 0); if (this.paintSession != null) {
if (this.paintSession == paintSession) return;
this.paintSession.endSession();
}
this.paintSession = paintSession;
- clearStatus();
if (paintSession != null) {
setStatusAction(paintSession.getDisplayName());
paintSession.beginSession();
} else {
setStatusAction(PaintPlugin.getResourceString("tool.Null.displayname"));
setStatusMessage(PaintPlugin.getResourceString("session.Null.message"));
}
}
+ clearStatus();
if (paintSession != null) {
setStatusAction(paintSession.getDisplayName());
paintSession.beginSession();
} else {
setStatusAction(PaintPlugin.getResourceString("tool.Null.label"));
setStatusMessage(PaintPlugin.getResourceString("session.Null.message"));
}
}
/**
* Returns the current paint session.
diff --git a/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PolyLineTool.java b/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PolyLineTool.java index 28ad66c00e..4d650f9ef9 100755 --- a/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PolyLineTool.java +++ b/examples/org.eclipse.swt.examples.paint/org/eclipse/swt/examples/paint/PolyLineTool.java @@ -39,7 +39,7 @@ public class PolyLineTool extends SegmentedPaintSession implements PaintTool { * @return the localized name of this tool
*/
public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.PolyLine.displayname");
+ return PaintPlugin.getResourceString("tool.PolyLine.label");
}
/*
diff --git a/examples/org.eclipse.swt.examples.paint/plugin.properties b/examples/org.eclipse.swt.examples.paint/plugin.properties index 3c8cd6030d..230cd503ea 100755 --- a/examples/org.eclipse.swt.examples.paint/plugin.properties +++ b/examples/org.eclipse.swt.examples.paint/plugin.properties @@ -65,7 +65,7 @@ tool.Text.settings.defaulttext = Hello! tool.Text.dialog.title = Text Tool Settings
tool.Text.dialog.message = Please enter the new text string to be painted.
-tool.Null.displayname = <none>
+tool.Null.label = <none>
fill.None.label = No Fill
fill.None.tooltip = No fill mode
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java index 0a179abdef..5cd1827e42 100755 --- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java +++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java @@ -7,7 +7,7 @@ package org.eclipse.swt.examples.paint;
/**
* Manages a simple drawing surface.
*/
public class PaintSurface {
private Point currentPosition = new Point(0, 0);
private Canvas paintCanvas;
private PaintSession paintSession;
private Image image;
private Image paintImage; // buffer for refresh blits
private int imageWidth, imageHeight;
private int visibleWidth, visibleHeight;
private FigureDrawContext displayFDC = new FigureDrawContext();
private FigureDrawContext imageFDC = new FigureDrawContext();
private FigureDrawContext paintFDC = new FigureDrawContext();
/* Rubberband */
private ContainerFigure rubberband = new ContainerFigure();
// the active rubberband selection
private int rubberbandHiddenNestingCount = 0;
// always >= 0, if > 0 rubberband has been hidden
/* Status */
private Text statusText;
private String statusActionInfo, statusMessageInfo, statusCoordInfo;
/**
* Constructs a PaintSurface.
* <p>
* paintCanvas must have SWT.NO_REDRAW_RESIZE and SWT.NO_BACKGROUND styles,
* and may have SWT.V_SCROLL and/or SWT.H_SCROLL.
* </p>
* @param paintCanvas the Canvas object in which to render
* @param paintStatus the PaintStatus object to use for providing user feedback
* @param fillColor the color to fill the canvas with initially
*/
- public PaintSurface(Canvas paintCanvas, Text statusText, Color fillColor) {
this.paintCanvas = paintCanvas;
this.statusText = statusText;
clearStatus();
/* Set up the drawing surface */
Rectangle displayRect = paintCanvas.getDisplay().getClientArea();
imageWidth = displayRect.width;
imageHeight = displayRect.height;
image = new Image(paintCanvas.getDisplay(), imageWidth, imageHeight);
imageFDC.gc = new GC(image);
imageFDC.gc.setBackground(fillColor);
imageFDC.gc.fillRectangle(0, 0, imageWidth, imageHeight);
displayFDC.gc = new GC(paintCanvas);
/* Initialize the session */
setPaintSession(null);
/* Add our listeners */
paintCanvas.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDown(event);
}
public void mouseUp(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseUp(event);
}
public void mouseDoubleClick(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDoubleClick(event);
}
});
paintCanvas.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseMove(event);
}
});
paintCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
if (rubberband.isEmpty()) {
event.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
} else {
// avoid flicker when merging overlayed objects
if (paintImage != null) {
Rectangle rect = paintImage.getBounds();
if ((event.width + event.x > rect.width) ||
(event.height + event.y > rect.height)) {
paintFDC.gc.dispose();
paintImage.dispose();
paintImage = null;
}
}
if (paintImage == null) {
Display display = getDisplay();
Rectangle rect = display.getClientArea();
paintImage = new Image(display,
Math.max(rect.width, event.width + event.x),
Math.max(rect.height, event.height + event.y));
paintFDC.gc = new GC(paintImage);
}
Region clipRegion = new Region();
event.gc.getClipping(clipRegion);
paintFDC.gc.setClipping(clipRegion);
clipRegion.dispose();
paintFDC.xOffset = displayFDC.xOffset;
paintFDC.yOffset = displayFDC.yOffset;
paintFDC.xScale = displayFDC.xScale;
paintFDC.yScale = displayFDC.yScale;
paintFDC.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
rubberband.draw(paintFDC);
event.gc.drawImage(paintImage,
event.x, event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
}
}
});
paintCanvas.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
handleResize();
}
});
/* Set up the paint canvas scroll bars */
ScrollBar horizontal = paintCanvas.getHorizontalBar();
horizontal.setVisible(true);
horizontal.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollHorizontally((ScrollBar)event.widget);
}
});
ScrollBar vertical = paintCanvas.getVerticalBar();
vertical.setVisible(true);
vertical.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollVertically((ScrollBar)event.widget);
}
});
handleResize();
}
/**
* Disposes of the PaintSurface's resources.
*/
public void dispose() {
imageFDC.gc.dispose();
displayFDC.gc.dispose();
image.dispose();
if (paintImage != null) {
paintImage.dispose();
paintFDC.gc.dispose();
}
currentPosition = null;
paintCanvas = null;
paintSession = null;
image = null;
paintImage = null;
displayFDC = null;
imageFDC = null;
paintFDC = null;
rubberband = null;
statusText = null;
statusActionInfo = null;
statusMessageInfo = null;
statusCoordInfo = null;
}
/**
* Called when we must grab focus.
*/
public void setFocus() {
paintCanvas.setFocus();
}
/**
* Returns the Display on which the PaintSurface resides.
* @return the Display
*/
public Display getDisplay() {
return paintCanvas.getDisplay();
}
/**
* Returns the Shell in which the PaintSurface resides.
* @return the Shell
*/
public Shell getShell() {
return paintCanvas.getShell();
}
/**
+ public PaintSurface(Canvas paintCanvas, Text statusText, Color fillColor) {
this.paintCanvas = paintCanvas;
this.statusText = statusText;
clearStatus();
/* Set up the drawing surface */
Rectangle displayRect = paintCanvas.getDisplay().getClientArea();
imageWidth = displayRect.width;
imageHeight = displayRect.height;
image = new Image(paintCanvas.getDisplay(), imageWidth, imageHeight);
imageFDC.gc = new GC(image);
imageFDC.gc.setBackground(fillColor);
imageFDC.gc.fillRectangle(0, 0, imageWidth, imageHeight);
displayFDC.gc = new GC(paintCanvas);
/* Initialize the session */
setPaintSession(null);
/* Add our listeners */
paintCanvas.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDown(event);
}
public void mouseUp(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseUp(event);
}
public void mouseDoubleClick(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseDoubleClick(event);
}
});
paintCanvas.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
processMouseEventCoordinates(event);
if (paintSession != null) paintSession.mouseMove(event);
}
});
paintCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
if (rubberband.isEmpty()) {
// Nothing to merge, so we just refresh
event.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
} else {
/*
* Avoid flicker when merging overlayed objects by constructing the image on
* a backbuffer first, then blitting it to the screen.
*/
// Check that the backbuffer is large enough
if (paintImage != null) {
Rectangle rect = paintImage.getBounds();
if ((event.width + event.x > rect.width) ||
(event.height + event.y > rect.height)) {
paintFDC.gc.dispose();
paintImage.dispose();
paintImage = null;
}
}
if (paintImage == null) {
Display display = getDisplay();
Rectangle rect = display.getClientArea();
paintImage = new Image(display,
Math.max(rect.width, event.width + event.x),
Math.max(rect.height, event.height + event.y));
paintFDC.gc = new GC(paintImage);
}
// Setup clipping and the FDC
Region clipRegion = new Region();
event.gc.getClipping(clipRegion);
paintFDC.gc.setClipping(clipRegion);
clipRegion.dispose();
paintFDC.xOffset = displayFDC.xOffset;
paintFDC.yOffset = displayFDC.yOffset;
paintFDC.xScale = displayFDC.xScale;
paintFDC.yScale = displayFDC.yScale;
// Merge the overlayed objects into the image, then blit
paintFDC.gc.drawImage(image,
displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
rubberband.draw(paintFDC);
event.gc.drawImage(paintImage,
event.x, event.y, event.width, event.height,
event.x, event.y, event.width, event.height);
}
}
});
paintCanvas.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
handleResize();
}
});
/* Set up the paint canvas scroll bars */
ScrollBar horizontal = paintCanvas.getHorizontalBar();
horizontal.setVisible(true);
horizontal.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollHorizontally((ScrollBar)event.widget);
}
});
ScrollBar vertical = paintCanvas.getVerticalBar();
vertical.setVisible(true);
vertical.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
scrollVertically((ScrollBar)event.widget);
}
});
handleResize();
}
/**
* Disposes of the PaintSurface's resources.
*/
public void dispose() {
imageFDC.gc.dispose();
displayFDC.gc.dispose();
image.dispose();
if (paintImage != null) {
paintImage.dispose();
paintFDC.gc.dispose();
}
currentPosition = null;
paintCanvas = null;
paintSession = null;
image = null;
paintImage = null;
displayFDC = null;
imageFDC = null;
paintFDC = null;
rubberband = null;
statusText = null;
statusActionInfo = null;
statusMessageInfo = null;
statusCoordInfo = null;
}
/**
* Called when we must grab focus.
*/
public void setFocus() {
paintCanvas.setFocus();
}
/**
* Returns the Display on which the PaintSurface resides.
* @return the Display
*/
public Display getDisplay() {
return paintCanvas.getDisplay();
}
/**
* Returns the Shell in which the PaintSurface resides.
* @return the Shell
*/
public Shell getShell() {
return paintCanvas.getShell();
}
/**
* Sets the current paint session.
* <p>
* If oldPaintSession != paintSession calls oldPaintSession.end()
* and paintSession.begin()
* </p>
*
* @param paintSession the paint session to activate; null to disable all sessions
@@ -16,7 +16,7 @@ public class PaintSurface {
private Point currentPosition = new Point(0, 0); if (this.paintSession != null) {
if (this.paintSession == paintSession) return;
this.paintSession.endSession();
}
this.paintSession = paintSession;
- clearStatus();
if (paintSession != null) {
setStatusAction(paintSession.getDisplayName());
paintSession.beginSession();
} else {
setStatusAction(PaintPlugin.getResourceString("tool.Null.displayname"));
setStatusMessage(PaintPlugin.getResourceString("session.Null.message"));
}
}
+ clearStatus();
if (paintSession != null) {
setStatusAction(paintSession.getDisplayName());
paintSession.beginSession();
} else {
setStatusAction(PaintPlugin.getResourceString("tool.Null.label"));
setStatusMessage(PaintPlugin.getResourceString("session.Null.message"));
}
}
/**
* Returns the current paint session.
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java index 28ad66c00e..4d650f9ef9 100755 --- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java +++ b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java @@ -39,7 +39,7 @@ public class PolyLineTool extends SegmentedPaintSession implements PaintTool { * @return the localized name of this tool
*/
public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.PolyLine.displayname");
+ return PaintPlugin.getResourceString("tool.PolyLine.label");
}
/*
|