diff dwt/internal/cocoa/NSAttributedString.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSAttributedString.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSAttributedString;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSDictionary;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSAttributedString : NSObject
+{
+    public this ()
+    {
+        this();
+    }
+
+    public this (objc.id id)
+    {
+        this(id);
+    }
+
+    public id attribute_atIndex_effectiveRange_ (NSString attrName, NSUInteger location, objc.id range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute_1atIndex_1effectiveRange_1, attrName !is null ? attrName.id : null, location,
+                range);
+        return result !is null ? new id(result) : null;
+    }
+
+    public id attribute_atIndex_longestEffectiveRange_inRange_ (NSString attrName, NSUInteger location, objc.id range, NSRange rangeLimit)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attribute_1atIndex_1longestEffectiveRange_1inRange_1,
+                attrName !is null ? attrName.id : null, location, range, rangeLimit);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSAttributedString attributedSubStringFromRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributedSubStringFromRange_1, range);
+        return result is this.id ? this : (result !is null ? new NSAttributedString(result) : null);
+    }
+
+    public NSDictionary attributesAtIndex_effectiveRange_ (int location, objc.id range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_1effectiveRange_1, location, range);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSDictionary attributesAtIndex_longestEffectiveRange_inRange_ (NSUInteger location, objc.id range, NSRange rangeLimit)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesAtIndex_1longestEffectiveRange_1inRange_1, location, range, rangeLimit);
+        return result !is null ? new NSDictionary(result) : null;
+    }
+
+    public NSAttributedString initWithAttributedString (NSAttributedString attrStr)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithAttributedString_1, attrStr !is null ? attrStr.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSAttributedString initWithString_ (NSString str)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, str !is null ? str.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSAttributedString initWithString_attributes_ (NSString str, NSDictionary attrs)
+    {
+        objc.id
+                result = OS.objc_msgSend(this.id, OS.sel_initWithString_1attributes_1, str !is null ? str.id : null, attrs !is null ? attrs.id : null);
+        return result !is null ? this : null;
+    }
+
+    public bool isEqualToAttributedString (NSAttributedString other)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToAttributedString_1, other !is null ? other.id : null) !is null;
+    }
+
+    public NSUInteger length ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_length);
+    }
+
+    public NSString String ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_String);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public NSSize size ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_size);
+        return result;
+    }
+
+    public void drawAtPoint (NSPoint pt)
+    {
+        OS.objc_msgSend(id, OS.sel_drawAtPoint_, pt);
+    }
+
+    public void drawInRect (NSRect rect)
+    {
+        OS.objc_msgSend(id, OS.sel_drawInRect_1, rect);
+    }
+
+    public void drawInRect (NSRect rect, objc.id options)
+    {
+        OS.objc_msgSend(id, OS.sel_drawInRect_1, rect, options);
+    }
+
+    public NSUInteger nextWordFromIndex (NSUInteger index, bool forward)
+    {
+        return OS.objc_msgSend(id, OS.sel_nextWordFromIndex_1forward_1, index, forward);
+    }
+
+    public NSRange doubleClickAtIndex (NSUInteger index)
+    {
+        NSRange result;
+        OS.objc_msgSend_struct(result, id, OS.sel_doubleClickAtIndex_1, index);
+        return result;
+    }
+}