Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSText.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | 642f460a0908 |
children | 62202ce0039f |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSText.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSText.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,21 +1,21 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSText; -import dwt.internal.cocoa.id; +import dwt.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; import dwt.internal.cocoa.NSColor; -import dwt.internal.cocoa.NSData; import dwt.internal.cocoa.NSFont; import dwt.internal.cocoa.NSRange; import dwt.internal.cocoa.NSSize; @@ -24,21 +24,6 @@ import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; - - -enum NSWritingDirection -{ - NSWritingDirectionNatural = -1, - NSWritingDirectionLeftToRight = 0, - NSWritingDirectionRightToLeft -} - -alias NSWritingDirection.NSWritingDirectionNatural NSWritingDirectionNatural; -alias NSWritingDirection.NSWritingDirectionLeftToRight NSWritingDirectionLeftToRight; -alias NSWritingDirection.NSWritingDirectionRightToLeft NSWritingDirectionRightToLeft; - - - enum NSTextAlignment { NSLeftTextAlignment = 0, @@ -48,393 +33,104 @@ NSNaturalTextAlignment = 4 } -alias NSTextAlignment.NSLeftTextAlignment NSLeftTextAlignment; -alias NSTextAlignment.NSRightTextAlignment NSRightTextAlignment; -alias NSTextAlignment.NSCenterTextAlignment NSCenterTextAlignment; -alias NSTextAlignment.NSJustifiedTextAlignment NSJustifiedTextAlignment; -alias NSTextAlignment.NSNaturalTextAlignment NSNaturalTextAlignment; - - - -public class NSText : NSView -{ - - public this () - { - super(); - } - - public this (objc.id id) - { - super(id); - } +public class NSText : NSView { + +public this() { + super(); +} - public static objc.Class static_class () - { - return cast(objc.Class) OS.objc_msgSend(OS.class_NSText, OS.sel_class); - } - - public NSData RTFDFromRange (NSRange range) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_RTFDFromRange_1, range); - return result !is null ? new NSData(result) : null; - } - - public NSData RTFFromRange (NSRange range) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_RTFFromRange_1, range); - return result !is null ? new NSData(result) : null; - } - - public void alignCenter (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_alignCenter_1, sender !is null ? sender.id_ : null); - } +public this(objc.id id) { + super(id); +} - public void alignLeft (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_alignLeft_1, sender !is null ? sender.id_ : null); - } - - public void alignRight (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_alignRight_1, sender !is null ? sender.id_ : null); - } - - public NSTextAlignment alignment () - { - return cast(NSTextAlignment) OS.objc_msgSend(this.id_, OS.sel_alignment); - } - - public NSColor backgroundColor () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor); - return result !is null ? new NSColor(result) : null; - } +public this(cocoa.id id) { + super(id); +} - public NSWritingDirection baseWritingDirection () - { - return cast(NSWritingDirection) OS.objc_msgSend(this.id_, OS.sel_baseWritingDirection); - } - - public void changeFont (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_changeFont_1, sender !is null ? sender.id_ : null); - } - - public void checkSpelling (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_checkSpelling_1, sender !is null ? sender.id_ : null); - } +public void copy(cocoa.id sender) { + OS.objc_msgSend(this.id, OS.sel_copy_, sender !is null ? sender.id : null); +} - public void copy (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_copy_1, sender !is null ? sender.id_ : null); - } - - public void copyFont (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_copyFont_1, sender !is null ? sender.id_ : null); - } - - public void copyRuler (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_copyRuler_1, sender !is null ? sender.id_ : null); - } +public void cut(cocoa.id sender) { + OS.objc_msgSend(this.id, OS.sel_cut_, sender !is null ? sender.id : null); +} - public void cut (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_cut_1, sender !is null ? sender.id_ : null); - } - - public id delegate_ () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate); - return result !is null ? new id(result) : null; - } - - public void deletee (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_delete_1, sender !is null ? sender.id_ : null); - } - - public bool drawsBackground () - { - return OS.objc_msgSend(this.id_, OS.sel_drawsBackground) !is null; - } +public void paste(cocoa.id sender) { + OS.objc_msgSend(this.id, OS.sel_paste_, sender !is null ? sender.id : null); +} - public NSFont font () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_font); - return result !is null ? new NSFont(result) : null; - } - - public bool importsGraphics () - { - return OS.objc_msgSend(this.id_, OS.sel_importsGraphics) !is null; - } +public void replaceCharactersInRange(NSRange range, NSString aString) { + OS.objc_msgSend(this.id, OS.sel_replaceCharactersInRange_withString_, range, aString !is null ? aString.id : null); +} - public bool isEditable () - { - return OS.objc_msgSend(this.id_, OS.sel_isEditable) !is null; - } - - public bool isFieldEditor () - { - return OS.objc_msgSend(this.id_, OS.sel_isFieldEditor) !is null; - } - - public bool isHorizontallyResizable () - { - return OS.objc_msgSend(this.id_, OS.sel_isHorizontallyResizable) !is null; - } +public void scrollRangeToVisible(NSRange range) { + OS.objc_msgSend(this.id, OS.sel_scrollRangeToVisible_, range); +} - public bool isRichText () - { - return OS.objc_msgSend(this.id_, OS.sel_isRichText) !is null; - } - - public bool isRulerVisible () - { - return OS.objc_msgSend(this.id_, OS.sel_isRulerVisible) !is null; - } - - public bool isSelectable () - { - return OS.objc_msgSend(this.id_, OS.sel_isSelectable) !is null; - } - - public bool isVerticallyResizable () - { - return OS.objc_msgSend(this.id_, OS.sel_isVerticallyResizable) !is null; - } +public void selectAll(cocoa.id sender) { + OS.objc_msgSend(this.id, OS.sel_selectAll_, sender !is null ? sender.id : null); +} - public NSSize maxSize () - { - NSSize result; - OS.objc_msgSend_stret(&result, this.id_, OS.sel_maxSize); - return result; - } - - public NSSize minSize () - { - NSSize result; - OS.objc_msgSend_stret(&result, this.id_, OS.sel_minSize); - return result; - } +public NSRange selectedRange() { + NSRange result = NSRange(); + OS.objc_msgSend_stret(result, this.id, OS.sel_selectedRange); + return result; +} - public void paste (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_paste_1, sender !is null ? sender.id_ : null); - } - - public void pasteFont (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_pasteFont_1, sender !is null ? sender.id_ : null); - } - - public void pasteRuler (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_pasteRuler_1, sender !is null ? sender.id_ : null); - } +public void setAlignment(NSTextAlignment mode) { + OS.objc_msgSend(this.id, OS.sel_setAlignment_, mode); +} - public bool readRTFDFromFile (NSString path) - { - return OS.objc_msgSend(this.id_, OS.sel_readRTFDFromFile_1, path !is null ? path.id_ : null) !is null; - } - - public void replaceCharactersInRange_withRTF_ (NSRange range, NSData rtfData) - { - OS.objc_msgSend(this.id_, OS.sel_replaceCharactersInRange_1withRTF_1, range, rtfData !is null ? rtfData.id_ : null); - } - - public void replaceCharactersInRange_withRTFD_ (NSRange range, NSData rtfdData) - { - OS.objc_msgSend(this.id_, OS.sel_replaceCharactersInRange_1withRTFD_1, range, rtfdData !is null ? rtfdData.id_ : null); - } - - public void replaceCharactersInRange_withString_ (NSRange range, NSString aString) - { - OS.objc_msgSend(this.id_, OS.sel_replaceCharactersInRange_1withString_1, range, aString !is null ? aString.id_ : null); - } +public void setBackgroundColor(NSColor color) { + OS.objc_msgSend(this.id, OS.sel_setBackgroundColor_, color !is null ? color.id : null); +} - public void scrollRangeToVisible (NSRange range) - { - OS.objc_msgSend(this.id_, OS.sel_scrollRangeToVisible_1, range); - } - - public void selectAll (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_selectAll_1, sender !is null ? sender.id_ : null); - } +public void setDelegate(cocoa.id anObject) { + OS.objc_msgSend(this.id, OS.sel_setDelegate_, anObject !is null ? anObject.id : null); +} - public NSRange selectedRange () - { - NSRange result; - OS.objc_msgSend_struct(&result, this.id_, OS.sel_selectedRange); - return result; - } - - public void setAlignment (NSTextAlignment mode) - { - OS.objc_msgSend(this.id_, OS.sel_setAlignment_1, mode); - } - - public void setBackgroundColor (NSColor color) - { - OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null); - } +public void setDrawsBackground(bool flag) { + OS.objc_msgSend(this.id, OS.sel_setDrawsBackground_, flag); +} - public void setBaseWritingDirection (NSWritingDirection writingDirection) - { - OS.objc_msgSend(this.id_, OS.sel_setBaseWritingDirection_1, writingDirection); - } - - public void setDelegate (id anObject) - { - OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null); - } - - public void setDrawsBackground (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setDrawsBackground_1, flag); - } - - public void setEditable (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setEditable_1, flag); - } - - public void setFieldEditor (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setFieldEditor_1, flag); - } +public void setEditable(bool flag) { + OS.objc_msgSend(this.id, OS.sel_setEditable_, flag); +} - public void setFont_ (NSFont obj) - { - OS.objc_msgSend(this.id_, OS.sel_setFont_1, obj !is null ? obj.id_ : null); - } - - public void setFont_range_ (NSFont font, NSRange range) - { - OS.objc_msgSend(this.id_, OS.sel_setFont_1range_1, font !is null ? font.id_ : null, range); - } +public void setFont(NSFont obj) { + OS.objc_msgSend(this.id, OS.sel_setFont_, obj !is null ? obj.id : null); +} - public void setHorizontallyResizable (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setHorizontallyResizable_1, flag); - } - - public void setImportsGraphics (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setImportsGraphics_1, flag); - } - - public void setMaxSize (NSSize newMaxSize) - { - OS.objc_msgSend(this.id_, OS.sel_setMaxSize_1, newMaxSize); - } +public void setHorizontallyResizable(bool flag) { + OS.objc_msgSend(this.id, OS.sel_setHorizontallyResizable_, flag); +} - public void setMinSize (NSSize newMinSize) - { - OS.objc_msgSend(this.id_, OS.sel_setMinSize_1, newMinSize); - } - - public void setRichText (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setRichText_1, flag); - } - - public void setSelectable (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setSelectable_1, flag); - } - - public void setSelectedRange (NSRange range) - { - OS.objc_msgSend(this.id_, OS.sel_setSelectedRange_1, range); - } - - public void setString (NSString string) - { - OS.objc_msgSend(this.id_, OS.sel_setString_1, string !is null ? string.id_ : null); - } +public void setMaxSize(NSSize newMaxSize) { + OS.objc_msgSend(this.id, OS.sel_setMaxSize_, newMaxSize); +} - public void setTextColor_ (NSColor color) - { - OS.objc_msgSend(this.id_, OS.sel_setTextColor_1, color !is null ? color.id_ : null); - } - - public void setTextColor_range_ (NSColor color, NSRange range) - { - OS.objc_msgSend(this.id_, OS.sel_setTextColor_1range_1, color !is null ? color.id_ : null, range); - } +public void setMinSize(NSSize newMinSize) { + OS.objc_msgSend(this.id, OS.sel_setMinSize_, newMinSize); +} - public void setUsesFontPanel (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setUsesFontPanel_1, flag); - } - - public void setVerticallyResizable (bool flag) - { - OS.objc_msgSend(this.id_, OS.sel_setVerticallyResizable_1, flag); - } - - public void showGuessPanel (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_showGuessPanel_1, sender !is null ? sender.id_ : null); - } +public void setSelectable(bool flag) { + OS.objc_msgSend(this.id, OS.sel_setSelectable_, flag); +} - public void sizeToFit () - { - OS.objc_msgSend(this.id_, OS.sel_sizeToFit); - } +public void setSelectedRange(NSRange range) { + OS.objc_msgSend(this.id, OS.sel_setSelectedRange_, range); +} - public NSString string () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_string); - return result !is null ? new NSString(result) : null; - } - - public void subscript (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_subscript_1, sender !is null ? sender.id_ : null); - } - - public void superscript (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_superscript_1, sender !is null ? sender.id_ : null); - } +public void setString(NSString string) { + OS.objc_msgSend(this.id, OS.sel_setString_, string !is null ? string.id : null); +} - public NSColor textColor () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_textColor); - return result !is null ? new NSColor(result) : null; - } - - public void toggleRuler (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_toggleRuler_1, sender !is null ? sender.id_ : null); - } +public void setTextColor(NSColor color) { + OS.objc_msgSend(this.id, OS.sel_setTextColor_, color !is null ? color.id : null); +} - public void underline (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_underline_1, sender !is null ? sender.id_ : null); - } - - public void unscript (id sender) - { - OS.objc_msgSend(this.id_, OS.sel_unscript_1, sender !is null ? sender.id_ : null); - } - - public bool usesFontPanel () - { - return OS.objc_msgSend(this.id_, OS.sel_usesFontPanel) !is null; - } - - public bool writeRTFDToFile (NSString path, bool flag) - { - return OS.objc_msgSend(this.id_, OS.sel_writeRTFDToFile_1atomically_1, path !is null ? path.id_ : null, flag) !is null; - } +public void sizeToFit() { + OS.objc_msgSend(this.id, OS.sel_sizeToFit); +} }