Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSTextBlock.d @ 13:f565d3a95c0a
Ported dwt.internal
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 22 Aug 2008 16:46:34 +0200 |
parents | 8b48be5454ce |
children |
line wrap: on
line source
/******************************************************************************* * 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.NSTextBlock; import dwt.internal.cocoa.CGFloat; import dwt.internal.cocoa.NSColor; import dwt.internal.cocoa.NSLayoutManager; import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSPoint; import dwt.internal.cocoa.NSRange; import dwt.internal.cocoa.NSRect; import dwt.internal.cocoa.NSTextContainer; import dwt.internal.cocoa.NSTextTable : NSTextBlockDimension, NSTextBlockLayer, NSTextBlockValueType, NSTextBlockVerticalAlignment; import dwt.internal.cocoa.NSView; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; public class NSTextBlock : NSObject { public this () { super(); } public this (objc.id id) { super(id); } public NSColor backgroundColor () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor); return result !is null ? new NSColor(result) : null; } public NSColor borderColorForEdge (NSRectEdge edge) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_borderColorForEdge_1, edge); return result !is null ? new NSColor(result) : null; } public NSRect boundsRectForContentRect (NSRect contentRect, NSRect rect, NSTextContainer textContainer, NSRange charRange) { NSRect result; OS.objc_msgSend_stret(&result, this.id_, OS.sel_boundsRectForContentRect_1inRect_1textContainer_1characterRange_1, contentRect, rect, textContainer !is null ? textContainer.id_ : null, charRange); return result; } public CGFloat contentWidth () { return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_contentWidth); } public NSTextBlockValueType contentWidthValueType () { return cast(NSTextBlockValueType) OS.objc_msgSend(this.id_, OS.sel_contentWidthValueType); } public void drawBackgroundWithFrame (NSRect frameRect, NSView controlView, NSRange charRange, NSLayoutManager layoutManager) { OS.objc_msgSend(this.id_, OS.sel_drawBackgroundWithFrame_1inView_1characterRange_1layoutManager_1, frameRect, controlView !is null ? controlView.id_ : null, charRange, layoutManager !is null ? layoutManager.id_ : null); } public NSRect rectForLayoutAtPoint (NSPoint startingPoint, NSRect rect, NSTextContainer textContainer, NSRange charRange) { NSRect result; OS.objc_msgSend_stret(&result, this.id_, OS.sel_rectForLayoutAtPoint_1inRect_1textContainer_1characterRange_1, startingPoint, rect, textContainer !is null ? textContainer.id_ : null, charRange); return result; } public void setBackgroundColor (NSColor color) { OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null); } public void setBorderColor_ (NSColor color) { OS.objc_msgSend(this.id_, OS.sel_setBorderColor_1, color !is null ? color.id_ : null); } public void setBorderColor_forEdge_ (NSColor color, NSRectEdge edge) { OS.objc_msgSend(this.id_, OS.sel_setBorderColor_1forEdge_1, color !is null ? color.id_ : null, edge); } public void setContentWidth (CGFloat val, NSTextBlockValueType type) { OS.objc_msgSend(this.id_, OS.sel_setContentWidth_1type_1, val, type); } public void setValue (CGFloat val, NSTextBlockValueType type, NSTextBlockDimension dimension) { OS.objc_msgSend(this.id_, OS.sel_setValue_1type_1forDimension_1, val, type, dimension); } public void setVerticalAlignment (NSTextBlockVerticalAlignment alignment) { OS.objc_msgSend(this.id_, OS.sel_setVerticalAlignment_1, alignment); } public void setWidth_type_forLayer_ (CGFloat val, NSTextBlockValueType type, NSTextBlockLayer layer) { OS.objc_msgSend(this.id_, OS.sel_setWidth_1type_1forLayer_1, val, type, layer); } public void setWidth_type_forLayer_edge_ (CGFloat val, NSTextBlockValueType type, NSTextBlockLayer layer, NSRectEdge edge) { OS.objc_msgSend(this.id_, OS.sel_setWidth_1type_1forLayer_1edge_1, val, type, layer, edge); } public CGFloat valueForDimension (NSTextBlockDimension dimension) { return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_valueForDimension_1, dimension); } public NSTextBlockValueType valueTypeForDimension (NSTextBlockDimension dimension) { return cast(NSTextBlockValueType) OS.objc_msgSend(this.id_, OS.sel_valueTypeForDimension_1, dimension); } public NSTextBlockVerticalAlignment verticalAlignment () { return cast(NSTextBlockVerticalAlignment) OS.objc_msgSend(this.id_, OS.sel_verticalAlignment); } public CGFloat widthForLayer (NSTextBlockLayer layer, NSRectEdge edge) { return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_widthForLayer_1edge_1, layer, edge); } public NSTextBlockValueType widthValueTypeForLayer (NSTextBlockLayer layer, NSRectEdge edge) { return cast(NSTextBlockValueType) OS.objc_msgSend(this.id_, OS.sel_widthValueTypeForLayer_1edge_1, layer, edge); } }