diff options
author | Silenio Quarti | 2007-11-15 06:46:10 +0000 |
---|---|---|
committer | Silenio Quarti | 2007-11-15 06:46:10 +0000 |
commit | 7a4847d4f107ddc8d45609baa603d1415611c02d (patch) | |
tree | 46f64767e26c70160dda0096213ac28d3fd315a4 | |
parent | 300ce6e9de094e9a6a19ad46539c21255641eb68 (diff) | |
download | eclipse.platform.swt-7a4847d4f107ddc8d45609baa603d1415611c02d.tar.gz eclipse.platform.swt-7a4847d4f107ddc8d45609baa603d1415611c02d.tar.xz eclipse.platform.swt-7a4847d4f107ddc8d45609baa603d1415611c02d.zip |
*** empty log message ***
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java | 31 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java | 2 |
2 files changed, 25 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java index 3c23045689..765597e7c5 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java @@ -34,6 +34,7 @@ import org.eclipse.swt.graphics.*; * @since 3.1 */ public class Link extends Control { + NSScrollView scrollView; String text; Point [] offsets; Point selection; @@ -118,13 +119,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) { if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; int width, height; + //TODO wrapping, wHint + int borderStyle = hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder; + NSSize borderSize = NSScrollView.frameSizeForContentSize(new NSSize(), false, false, borderStyle); NSTextView widget = (NSTextView)view; - NSRect oldRect = widget.frame(); - widget.sizeToFit(); - NSRect newRect = widget.frame(); - widget.setFrame (oldRect); - width = (int)newRect.width; - height = (int)newRect.height; + NSSize size = widget.textStorage().size(); + width = (int)(size.width + borderSize.width); + height = (int)(size.height + borderSize.height); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; int border = getBorderWidth (); @@ -134,14 +135,26 @@ public Point computeSize (int wHint, int hHint, boolean changed) { } void createHandle () { + SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc(); + scrollWidget.initWithFrame(new NSRect ()); + scrollWidget.setDrawsBackground(false); + scrollWidget.setBorderType(hasBorder() ? OS.NSBezelBorder : OS.NSNoBorder); + scrollWidget.setTag(jniRef); + SWTTextView widget = (SWTTextView)new SWTTextView().alloc(); widget.initWithFrame(new NSRect()); widget.setEditable(false); widget.setDrawsBackground(false); widget.setDelegate(widget); + widget.setAutoresizingMask (OS.NSViewWidthSizable | OS.NSViewHeightSizable); widget.setTag(jniRef); + widget.textContainer().setLineFragmentPadding(0); + + scrollView = scrollWidget; view = widget; - parent.contentView().addSubview_(widget); + scrollView.addSubview_(view); + scrollView.setDocumentView(view); + parent.contentView().addSubview_(scrollView); } void createWidget () { @@ -391,6 +404,10 @@ public void setText (String string) { } } +NSView topView () { + return scrollView; +} + //int traversalCode (int key, int theEvent) { // if (offsets.length == 0) return 0; // int bits = super.traversalCode (key, theEvent); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java index cd7ff7a14c..1010c6841e 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java @@ -41,7 +41,7 @@ public class Spinner extends Composite { int pageIncrement = 10; int digits = 0; - static int GAP = 3; + static int GAP = 0; /** * Constructs a new instance of this class given its parent |