diff options
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/motif')
5 files changed, 212 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java index c21fdc387b..709fd8f4a1 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java @@ -62,9 +62,13 @@ GC() { * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> * </ul> */ -public GC (Drawable drawable) { +public GC(Drawable drawable) { + this(drawable, 0); +} +public GC(Drawable drawable, int style) { if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); GCData data = new GCData(); + data.style = checkStyle(style); int xGC = drawable.internal_new_GC(data); Device device = data.device; if (device == null) device = Device.getDevice(); @@ -73,7 +77,10 @@ public GC (Drawable drawable) { init(drawable, data, xGC); if (device.tracking) device.new_Object(this); } - +static int checkStyle (int style) { + if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT; + return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); +} /** * Copies a rectangular area of the receiver at the source * position onto the receiver at the destination position. @@ -2048,6 +2055,10 @@ public int getLineWidth() { OS.XGetGCValues(data.display, handle, OS.GCLineWidth, values); return values.line_width; } +public int getStyle () { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + return data.style; +} /** * Returns <code>true</code> if this GC is drawing in the mode * where the resulting color in the destination is the diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java index 08a2b3e969..f1e18d875b 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java @@ -25,6 +25,7 @@ import org.eclipse.swt.*; */ public final class GCData { public Device device; + public int style; public Image image; public int display; public int drawable; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java index 916eb85d1b..6b96c0feb1 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java @@ -1050,6 +1050,10 @@ public int internal_new_GC (GCData data) { int xGC = OS.XCreateGC (xDisplay, pixmap, 0, null); if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES); if (data != null) { + int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; + if ((data.style & mask) == 0) { + data.style |= SWT.LEFT_TO_RIGHT; + } data.device = device; data.display = xDisplay; data.drawable = pixmap; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java index c6d1b00c6e..d6d2bb9534 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java @@ -1061,6 +1061,10 @@ public int internal_new_GC (GCData data) { int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNcolormap, 0}; OS.XtGetValues (handle, argList, argList.length / 2); if (data != null) { + int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; + if ((data.style & mask) == 0) { + data.style |= style & (mask | SWT.MIRRORED); + } data.device = getDisplay (); data.display = xDisplay; data.drawable = xWindow; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java index d4890b73aa..6f18f0fa22 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java @@ -1618,6 +1618,10 @@ public int internal_new_GC (GCData data) { if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES); OS.XSetSubwindowMode (xDisplay, xGC, OS.IncludeInferiors); if (data != null) { + int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; + if ((data.style & mask) == 0) { + data.style |= SWT.LEFT_TO_RIGHT; + } data.device = this; data.display = xDisplay; data.drawable = xDrawable; @@ -1651,6 +1655,192 @@ static boolean isValidClass (Class clazz) { int index = name.lastIndexOf ('.'); return name.substring (0, index + 1).equals (PACKAGE_PREFIX); } +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + * <p> + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + * </p> + * + * @param from the source <code>Control</code> or <code>null</code> + * @param to the destination <code>Control</code> or <code>null</code> + * @param point to be mapped + * @return point with mapped coordinates + * + * @exception SWTException <ul> + * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> + * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 2.1.2 + */ +public Point map (Control from, Control to, Point point) { + checkDevice (); + if (point == null) error (SWT.ERROR_NULL_ARGUMENT); + return map (from, to, point.x, point.y); +} +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + * <p> + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + * </p> + * + * @param from the source <code>Control</code> or <code>null</code> + * @param to the destination <code>Control</code> or <code>null</code> + * @param int x coordinates to be mapped + * @param int y coordinates to be mapped + * @return point with mapped coordinates + * + * @exception SWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> + * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 2.1.2 + */ +public Point map (Control from, Control to, int x, int y) { + checkDevice (); + if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + Point point = new Point (x, y); + if (from != null) { + short [] root_x = new short [1], root_y = new short [1]; + OS.XtTranslateCoords (from.handle, (short) x, (short) y, root_x, root_y); + point.x = root_x [0]; + point.y = root_y [0]; + } + if (to != null) { + short [] root_x = new short [1], root_y = new short [1]; + OS.XtTranslateCoords (to.handle, (short) 0, (short) 0, root_x, root_y); + point.x -= root_x [0]; + point.y -= root_y [0]; + } + return point; +} +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + * <p> + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + * </p> + * + * @param from the source <code>Control</code> or <code>null</code> + * @param to the destination <code>Control</code> or <code>null</code> + * @param rectangle to be mapped + * @return rectangle with mapped coordinates + * + * @exception SWTException <ul> + * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> + * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 2.1.2 + */ +public Rectangle map (Control from, Control to, Rectangle rectangle) { + checkDevice(); + if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT); + return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); +} +/** + * Maps a point from one coordinate system to another. + * When the control is null, coordinates are mapped to + * the display. + * <p> + * NOTE: On right-to-left platforms where the coordinate + * systems are mirrored, special care needs to be taken + * when mapping coordinates from one control to another + * to ensure the result is correctly mirrored. + * + * Mapping a point that is the origin of a rectangle and + * then adding the width and height is not equivalent to + * mapping the rectangle. When one control is mirrored + * and the other is not, adding the width and height to a + * point that was mapped causes the rectangle to extend + * in the wrong direction. Mapping the entire rectangle + * instead of just one point causes both the origin and + * the corner of the rectangle to be mapped. + * </p> + * + * @param from the source <code>Control</code> or <code>null</code> + * @param to the destination <code>Control</code> or <code>null</code> + * @param int x coordinates to be mapped + * @param int y coordinates to be mapped + * @param int width coordinates to be mapped + * @param int heigth coordinates to be mapped + * @return rectangle with mapped coordinates + * + * @exception SWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> + * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 2.1.2 + */ +public Rectangle map (Control from, Control to, int x, int y, int width, int height) { + checkDevice(); + if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); + Rectangle rect = new Rectangle (x, y, width, height); + if (from != null) { + short [] root_x = new short [1], root_y = new short [1]; + OS.XtTranslateCoords (from.handle, (short) x, (short) y, root_x, root_y); + rect.x = root_x [0]; + rect.y = root_y [0]; + } + if (to != null) { + short [] root_x = new short [1], root_y = new short [1]; + OS.XtTranslateCoords (to.handle, (short) 0, (short) 0, root_x, root_y); + rect.x -= root_x [0]; + rect.y -= root_y [0]; + } + return rect; +} int mouseHoverProc (int handle, int id) { mouseHoverID = mouseHoverHandle = 0; Widget widget = WidgetTable.get (handle); |