From d77fd0933ebe489c9b42022eb9c894092dd1d274 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Mon, 29 Jan 2007 20:05:53 +0000 Subject: making MacOS X 10.3 the target platform --- .../carbon/org/eclipse/swt/graphics/Cursor.java | 60 +------------------ .../carbon/org/eclipse/swt/graphics/GC.java | 18 +++--- .../org/eclipse/swt/graphics/TextLayout.java | 10 ++-- .../carbon/org/eclipse/swt/widgets/Text.java | 70 +++++++++------------- 4 files changed, 42 insertions(+), 116 deletions(-) (limited to 'bundles/org.eclipse.swt/Eclipse SWT/carbon/org') diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java index d79759d57f..7686a0a38d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java @@ -56,46 +56,6 @@ public final class Cursor extends Resource { static boolean initialized; - /** - * data and mask used to create a Resize NS Cursor - */ - static final byte [] SIZENS_SOURCE = new byte[] { - (byte)0x00, (byte)0x00, - (byte)0x01, (byte)0x80, - (byte)0x03, (byte)0xC0, - (byte)0x07, (byte)0xE0, - (byte)0x01, (byte)0x80, - (byte)0x01, (byte)0x80, - (byte)0x01, (byte)0x80, - (byte)0x7F, (byte)0xFE, - (byte)0x7F, (byte)0xFE, - (byte)0x01, (byte)0x80, - (byte)0x01, (byte)0x80, - (byte)0x01, (byte)0x80, - (byte)0x07, (byte)0xE0, - (byte)0x03, (byte)0xC0, - (byte)0x01, (byte)0x80, - (byte)0x00, (byte)0x00, - }; - static final byte [] SIZENS_MASK = new byte[] { - (byte)0x01, (byte)0x80, - (byte)0x03, (byte)0xC0, - (byte)0x07, (byte)0xE0, - (byte)0x0F, (byte)0xF0, - (byte)0x0F, (byte)0xF0, - (byte)0x03, (byte)0xC0, - (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, - (byte)0xFF, (byte)0xFF, - (byte)0x03, (byte)0xC0, - (byte)0x0F, (byte)0xF0, - (byte)0x0F, (byte)0xF0, - (byte)0x07, (byte)0xE0, - (byte)0x03, (byte)0xC0, - (byte)0x01, (byte)0x80, - }; - /** * Prevents uninitialized instances from being created outside the package. */ @@ -156,25 +116,11 @@ public Cursor(Device device, int style) { case SWT.CURSOR_HELP: handle = OS.kThemeCrossCursor; break; case SWT.CURSOR_SIZEALL: handle = OS.kThemeCrossCursor; break; case SWT.CURSOR_SIZENESW: handle = OS.kThemeCrossCursor; break; - case SWT.CURSOR_SIZENS: { - if (OS.VERSION >= 0x1030) { - handle = OS.kThemeResizeUpDownCursor; - } else { - org.eclipse.swt.internal.carbon.Cursor cursor = new org.eclipse.swt.internal.carbon.Cursor(); - cursor.data = SIZENS_SOURCE; - cursor.mask = SIZENS_MASK; - cursor.hotSpot_h = 7; - cursor.hotSpot_v = 7; - handle = OS.NewPtr(org.eclipse.swt.internal.carbon.Cursor.sizeof); - if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); - OS.memcpy(handle, cursor, org.eclipse.swt.internal.carbon.Cursor.sizeof); - } - break; - } + case SWT.CURSOR_SIZENS: handle = OS.kThemeResizeUpDownCursor; break; case SWT.CURSOR_SIZENWSE: handle = OS.kThemeCrossCursor; break; case SWT.CURSOR_SIZEWE: handle = OS.kThemeResizeLeftRightCursor; break; - case SWT.CURSOR_SIZEN: handle = OS.VERSION >= 0x1030 ? OS.kThemeResizeUpCursor : OS.kThemeCrossCursor; break; - case SWT.CURSOR_SIZES: handle = OS.VERSION >= 0x1030 ? OS.kThemeResizeDownCursor : OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZEN: handle = OS.kThemeResizeUpCursor; break; + case SWT.CURSOR_SIZES: handle = OS.kThemeResizeDownCursor; break; case SWT.CURSOR_SIZEE: handle = OS.kThemeResizeRightCursor; break; case SWT.CURSOR_SIZEW: handle = OS.kThemeResizeLeftCursor; break; case SWT.CURSOR_SIZENE: handle = OS.kThemeCrossCursor; break; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java index 20f61362f0..8b06182be9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java @@ -772,16 +772,14 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int arc public void drawFocus(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (data.updateClip) setCGClipping(); - if (OS.VERSION >= 0x1030) { - int[] metric = new int[1]; - OS.GetThemeMetric(OS.kThemeMetricFocusRectOutset, metric); - CGRect rect = new CGRect (); - rect.x = x + metric[0]; - rect.y = y + metric[0]; - rect.width = width - metric[0] * 2; - rect.height = height - metric[0] * 2; - OS.HIThemeDrawFocusRect(rect, true, handle, OS.kHIThemeOrientationNormal); - } + int[] metric = new int[1]; + OS.GetThemeMetric(OS.kThemeMetricFocusRectOutset, metric); + CGRect rect = new CGRect (); + rect.x = x + metric[0]; + rect.y = y + metric[0]; + rect.width = width - metric[0] * 2; + rect.height = height - metric[0] * 2; + OS.HIThemeDrawFocusRect(rect, true, handle, OS.kHIThemeOrientationNormal); flush(); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java index f18ce838c5..9edaf103c7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java @@ -443,12 +443,10 @@ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Colo boolean hasSelection = selectionStart <= selectionEnd && selectionStart != -1 && selectionEnd != -1; boolean restoreColor = false; if (hasSelection && selectionBackground != null) { - if (OS.VERSION >= 0x1030) { - restoreColor = true; - int color = OS.CGColorCreate(device.colorspace, selectionBackground.handle); - setLayoutControl(OS.kATSULineHighlightCGColorTag, color, 4); - OS.CGColorRelease(color); - } + restoreColor = true; + int color = OS.CGColorCreate(device.colorspace, selectionBackground.handle); + setLayoutControl(OS.kATSULineHighlightCGColorTag, color, 4); + OS.CGColorRelease(color); } /* * Feature in ATSU. There is no API to set a background attribute diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java index 636fa80f82..3ff0204151 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java @@ -15,7 +15,6 @@ import org.eclipse.swt.internal.carbon.OS; import org.eclipse.swt.internal.carbon.RGBColor; import org.eclipse.swt.internal.carbon.Rect; import org.eclipse.swt.internal.carbon.TXNBackground; -import org.eclipse.swt.internal.carbon.TXNLongRect; import org.eclipse.swt.internal.carbon.ControlEditTextSelectionRec; import org.eclipse.swt.internal.carbon.ControlFontStyleRec; import org.eclipse.swt.internal.carbon.CFRange; @@ -319,29 +318,22 @@ public Point computeSize (int wHint, int hHint, boolean changed) { // if (ptr2 [0] != 0) OS.CFRelease (ptr2 [0]); } } else { - if (OS.VERSION >= 0x1030) { - int [] oDataHandle = new int [1]; - OS.TXNGetData (txnObject, OS.kTXNStartOffset, OS.kTXNEndOffset, oDataHandle); - if (oDataHandle [0] != 0) { - int length = OS.GetHandleSize (oDataHandle [0]), str = 0; - if (length != 0) { - int [] ptr = new int [1]; - OS.HLock (oDataHandle [0]); - OS.memcpy (ptr, oDataHandle [0], 4); - str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, ptr [0], length / 2); - OS.HUnlock (oDataHandle[0]); - } - OS.DisposeHandle (oDataHandle[0]); - Point size = textExtent (str, wHint == SWT.DEFAULT ? 0 : wHint); - if (str != 0) OS.CFRelease(str); - width = size.x; - height = size.y; + int [] oDataHandle = new int [1]; + OS.TXNGetData (txnObject, OS.kTXNStartOffset, OS.kTXNEndOffset, oDataHandle); + if (oDataHandle [0] != 0) { + int length = OS.GetHandleSize (oDataHandle [0]), str = 0; + if (length != 0) { + int [] ptr = new int [1]; + OS.HLock (oDataHandle [0]); + OS.memcpy (ptr, oDataHandle [0], 4); + str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, ptr [0], length / 2); + OS.HUnlock (oDataHandle[0]); } - } else { - TXNLongRect oTextRect = new TXNLongRect (); - OS.TXNGetRectBounds (txnObject, null, null, oTextRect); - width = oTextRect.right - oTextRect.left; - height = oTextRect.bottom - oTextRect.top; + OS.DisposeHandle (oDataHandle[0]); + Point size = textExtent (str, wHint == SWT.DEFAULT ? 0 : wHint); + if (str != 0) OS.CFRelease(str); + width = size.x; + height = size.y; } } if (width <= 0) width = DEFAULT_WIDTH; @@ -624,13 +616,13 @@ public Point getCaretLocation () { //TODO - caret location for unicode text return new Point (0, 0); } - org.eclipse.swt.internal.carbon.Point oPoint = new org.eclipse.swt.internal.carbon.Point (); + CGPoint oPoint = new CGPoint (); int [] oStartOffset = new int [1], oEndOffset = new int [1]; OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); - OS.TXNOffsetToPoint (txnObject, oStartOffset [0], oPoint); + OS.TXNOffsetToHIPoint (txnObject, oStartOffset [0], oPoint); Rect oViewRect = new Rect (); OS.TXNGetViewRect (txnObject, oViewRect); - return new Point (oPoint.h - oViewRect.left, oPoint.v - oViewRect.top); + return new Point ((int) oPoint.x - oViewRect.left, (int) oPoint.y - oViewRect.top); } /** @@ -836,10 +828,10 @@ int getPosition (int x, int y) { int [] oOffset = new int [1]; Rect oViewRect = new Rect (); OS.TXNGetViewRect (txnObject, oViewRect); - org.eclipse.swt.internal.carbon.Point iPoint = new org.eclipse.swt.internal.carbon.Point (); - iPoint.h = (short) (x + oViewRect.left); - iPoint.v = (short) (y + oViewRect.top); - return OS.TXNPointToOffset (txnObject, iPoint, oOffset) == OS.noErr ? oOffset [0] : -1; + CGPoint iPoint = new CGPoint (); + iPoint.x = x + oViewRect.left; + iPoint.y = y + oViewRect.top; + return OS.TXNHIPointToOffset (txnObject, iPoint, oOffset) == OS.noErr ? oOffset [0] : -1; } public int getPosition (Point point) { @@ -1090,19 +1082,11 @@ public int getTopIndex () { public int getTopPixel () { checkWidget(); if ((style & SWT.SINGLE) != 0) return 0; - if (OS.VERSION >= 0x1030) { - CGRect rect = new CGRect (); - OS.TXNGetHIRect (txnObject, OS.kTXNDestinationRectKey, rect); - int destY = (int) rect.y; - OS.TXNGetHIRect (txnObject, OS.kTXNTextRectKey, rect); - return destY - (int) rect.y; - } else { - Rect oViewRect = new Rect (); - TXNLongRect oDestinationRect = new TXNLongRect (); - TXNLongRect oTextRect = new TXNLongRect (); - OS.TXNGetRectBounds (txnObject, oViewRect, oDestinationRect, oTextRect); - return oDestinationRect.top - oTextRect.top; - } + CGRect rect = new CGRect (); + OS.TXNGetHIRect (txnObject, OS.kTXNDestinationRectKey, rect); + int destY = (int) rect.y; + OS.TXNGetHIRect (txnObject, OS.kTXNTextRectKey, rect); + return destY - (int) rect.y; } String getTXNText (int iStartOffset, int iEndOffset) { -- cgit