view dstep/appkit/NSTextTable.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents
children b9de51448c6b
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Sep 24, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.appkit.NSTextTable;

import dstep.appkit.NSColor;
import dstep.appkit.NSLayoutManager;
import dstep.appkit.NSText;
import dstep.appkit.NSTextContainer;
import dstep.appkit.NSView;
import dstep.applicationservices.coregraphics.CGBase;
import dstep.foundation.NSCoder;
import dstep.foundation.NSGeometry;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSRange;
import dstep.foundation.NSZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

typedef NSUInteger NSTextBlockValueType;
typedef NSUInteger NSTextBlockDimension;
typedef NSInteger NSTextBlockLayer;
typedef NSUInteger NSTextBlockVerticalAlignment;
typedef NSUInteger NSTextTableLayoutAlgorithm;

enum : NSUInteger
{
	NSTextBlockAbsoluteValueType = 0,
	NSTextBlockPercentageValueType = 1
}

enum : NSUInteger
{
	NSTextBlockWidth = 0,
	NSTextBlockMinimumWidth = 1,
	NSTextBlockMaximumWidth = 2,
	NSTextBlockHeight = 4,
	NSTextBlockMinimumHeight = 5,
	NSTextBlockMaximumHeight = 6
}

enum : NSInteger
{
	NSTextBlockPadding = -1,
	NSTextBlockBorder = 0,
	NSTextBlockMargin = 1
}

enum : NSUInteger
{
	NSTextBlockTopAlignment = 0,
	NSTextBlockMiddleAlignment = 1,
	NSTextBlockBottomAlignment = 2,
	NSTextBlockBaselineAlignment = 3
}

enum : NSUInteger
{
	NSTextTableAutomaticLayoutAlgorithm = 0,
	NSTextTableFixedLayoutAlgorithm = 1
}

class NSTextTable : NSTextBlock
{
	mixin (ObjcWrap);

	NSUInteger numberOfColumns ()
	{
		return invokeObjcSelf!(NSUInteger, "numberOfColumns");
	}

	void setNumberOfColumns (NSUInteger numCols)
	{
		return invokeObjcSelf!(void, "setNumberOfColumns:", NSUInteger)(numCols);
	}

	uint layoutAlgorithm ()
	{
		return invokeObjcSelf!(uint, "layoutAlgorithm");
	}

	void setLayoutAlgorithm (uint algorithm)
	{
		return invokeObjcSelf!(void, "setLayoutAlgorithm:", uint)(algorithm);
	}

	bool collapsesBorders ()
	{
		return invokeObjcSelf!(bool, "collapsesBorders");
	}

	void setCollapsesBorders (bool flag)
	{
		return invokeObjcSelf!(void, "setCollapsesBorders:", bool)(flag);
	}

	bool hidesEmptyCells ()
	{
		return invokeObjcSelf!(bool, "hidesEmptyCells");
	}

	void setHidesEmptyCells (bool flag)
	{
		return invokeObjcSelf!(void, "setHidesEmptyCells:", bool)(flag);
	}

	NSRect rectForBlock (NSTextTableBlock block, NSPoint startingPoint, NSRect rect, NSTextContainer textContainer, NSRange charRange)
	{
		return invokeObjcSelf!(NSRect, "rectForBlock:layoutAtPoint:inRect:textContainer:characterRange:", NSTextTableBlock, NSPoint, NSRect, NSTextContainer, NSRange)(block, startingPoint, rect, textContainer, charRange);
	}

	NSRect boundsRectForBlock (NSTextTableBlock block, NSRect contentRect, NSRect rect, NSTextContainer textContainer, NSRange charRange)
	{
		return invokeObjcSelf!(NSRect, "boundsRectForBlock:contentRect:inRect:textContainer:characterRange:", NSTextTableBlock, NSRect, NSRect, NSTextContainer, NSRange)(block, contentRect, rect, textContainer, charRange);
	}

	void drawBackgroundForBlock (NSTextTableBlock block, NSRect frameRect, NSView controlView, NSRange charRange, NSLayoutManager layoutManager)
	{
		return invokeObjcSelf!(void, "drawBackgroundForBlock:withFrame:inView:characterRange:layoutManager:", NSTextTableBlock, NSRect, NSView, NSRange, NSLayoutManager)(block, frameRect, controlView, charRange, layoutManager);
	}
}

class NSTextBlock : NSObject, INSCoding, INSCopying
{
	mixin (ObjcWrap);
	
	this (NSCoder aDecoder)
	{
		super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
	}
	
	void encodeWithCoder (NSCoder aCoder)
	{
		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
	}
	
	typeof(this) initWithCoder (NSCoder aDecoder)
	{
		return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
	}
	
	typeof(this) copyWithZone (NSZone* zone)
	{
		return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone);
	}

	NSTextBlock init ()
	{
		id result = invokeObjcSelf!(id, "init");
		return result is this.objcObject ? this : (result !is null ? new NSTextBlock(result) : null);
	}

	this ()
	{
		super(NSTextBlock.alloc.init.objcObject);
	}

	void setValue (CGFloat val, uint type, uint dimension)
	{
		return invokeObjcSelf!(void, "setValue:type:forDimension:", CGFloat, uint, uint)(val, type, dimension);
	}

	CGFloat valueForDimension (uint dimension)
	{
		return invokeObjcSelf!(CGFloat, "valueForDimension:", uint)(dimension);
	}

	uint valueTypeForDimension (uint dimension)
	{
		return invokeObjcSelf!(uint, "valueTypeForDimension:", uint)(dimension);
	}

	void setContentWidth (CGFloat val, uint type)
	{
		return invokeObjcSelf!(void, "setContentWidth:type:", CGFloat, uint)(val, type);
	}

	CGFloat contentWidth ()
	{
		return invokeObjcSelf!(CGFloat, "contentWidth");
	}

	uint contentWidthValueType ()
	{
		return invokeObjcSelf!(uint, "contentWidthValueType");
	}

	void setWidth (CGFloat val, uint type, int layer, int edge)
	{
		return invokeObjcSelf!(void, "setWidth:type:forLayer:edge:", CGFloat, uint, int, int)(val, type, layer, edge);
	}

	void setWidth (CGFloat val, uint type, int layer)
	{
		return invokeObjcSelf!(void, "setWidth:type:forLayer:", CGFloat, uint, int)(val, type, layer);
	}

	CGFloat widthForLayer (int layer, int edge)
	{
		return invokeObjcSelf!(CGFloat, "widthForLayer:edge:", int, int)(layer, edge);
	}

	uint widthValueTypeForLayer (int layer, int edge)
	{
		return invokeObjcSelf!(uint, "widthValueTypeForLayer:edge:", int, int)(layer, edge);
	}

	void setVerticalAlignment (uint alignment)
	{
		return invokeObjcSelf!(void, "setVerticalAlignment:", uint)(alignment);
	}

	uint verticalAlignment ()
	{
		return invokeObjcSelf!(uint, "verticalAlignment");
	}

	void setBackgroundColor (NSColor color)
	{
		return invokeObjcSelf!(void, "setBackgroundColor:", NSColor)(color);
	}

	NSColor backgroundColor ()
	{
		return invokeObjcSelf!(NSColor, "backgroundColor");
	}

	void setBorderColor (NSColor color, int edge)
	{
		return invokeObjcSelf!(void, "setBorderColor:forEdge:", NSColor, int)(color, edge);
	}

	void setBorderColor (NSColor color)
	{
		return invokeObjcSelf!(void, "setBorderColor:", NSColor)(color);
	}

	NSColor borderColorForEdge (int edge)
	{
		return invokeObjcSelf!(NSColor, "borderColorForEdge:", int)(edge);
	}

	NSRect rectForLayoutAtPoint (NSPoint startingPoint, NSRect rect, NSTextContainer textContainer, NSRange charRange)
	{
		return invokeObjcSelf!(NSRect, "rectForLayoutAtPoint:inRect:textContainer:characterRange:", NSPoint, NSRect, NSTextContainer, NSRange)(startingPoint, rect, textContainer, charRange);
	}

	NSRect boundsRectForContentRect (NSRect contentRect, NSRect rect, NSTextContainer textContainer, NSRange charRange)
	{
		return invokeObjcSelf!(NSRect, "boundsRectForContentRect:inRect:textContainer:characterRange:", NSRect, NSRect, NSTextContainer, NSRange)(contentRect, rect, textContainer, charRange);
	}

	void drawBackgroundWithFrame (NSRect frameRect, NSView controlView, NSRange charRange, NSLayoutManager layoutManager)
	{
		return invokeObjcSelf!(void, "drawBackgroundWithFrame:inView:characterRange:layoutManager:", NSRect, NSView, NSRange, NSLayoutManager)(frameRect, controlView, charRange, layoutManager);
	}

}

class NSTextTableBlock : NSTextBlock
{
	mixin (ObjcWrap);

	NSTextTableBlock initWithTable (NSTextTable table, NSInteger row, NSInteger rowSpan, NSInteger col, NSInteger colSpan)
	{
		id result = invokeObjcSelf!(id, "initWithTable:startingRow:rowSpan:startingColumn:columnSpan:", NSTextTable, NSInteger, NSInteger, NSInteger, NSInteger)(table, row, rowSpan, col, colSpan);
		return result is this.objcObject ? this : (result !is null ? new NSTextTableBlock(result) : null);
	}

	this (NSTextTable table, NSInteger row, NSInteger rowSpan, NSInteger col, NSInteger colSpan)
	{
		super(NSTextTableBlock.alloc.initWithTable(table, row, rowSpan, col, colSpan).objcObject);
	}

	NSTextTable table ()
	{
		return invokeObjcSelf!(NSTextTable, "table");
	}

	NSInteger startingRow ()
	{
		return invokeObjcSelf!(NSInteger, "startingRow");
	}

	NSInteger rowSpan ()
	{
		return invokeObjcSelf!(NSInteger, "rowSpan");
	}

	NSInteger startingColumn ()
	{
		return invokeObjcSelf!(NSInteger, "startingColumn");
	}

	NSInteger columnSpan ()
	{
		return invokeObjcSelf!(NSInteger, "columnSpan");
	}
}