view dstep/appkit/NSMatrix.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.NSMatrix;

import dstep.appkit.NSCell;
import dstep.appkit.NSColor;
import dstep.appkit.NSControl;
import dstep.appkit.NSEvent;
import dstep.appkit.NSText;
import dstep.appkit.NSUserInterfaceValidation;
import dstep.foundation.NSArray;
import dstep.foundation.NSGeometry;
import dstep.foundation.NSNotification;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

alias NSUInteger NSMatrixMode;

private alias extern (C) NSInteger function (id, id, void *) Comperator; 

enum
{
	NSRadioModeMatrix = 0,
	NSHighlightModeMatrix = 1,
	NSListModeMatrix = 2,
	NSTrackModeMatrix = 3
}

struct _MFlags
{
	uint reservedMatrix;
	uint browserOptimizationsEnabled;
	uint needsRedrawBeforeFirstLiveResizeCache;
	uint tmpAllowNonVisibleCellsToBecomeFirstResponder;
	uint subclassIsSafeForLiveResize;
	uint hasCachedSubclassIsSafeForLiveResize;
	uint liveResizeImageCacheingEnabled;
	uint checkForSimpleTrackingMode;
	uint useSimpleTrackingMode;
	uint refusesFirstResponder;
	uint dontScroll;
	uint changingSelectionWithKeyboard;
	uint onlySetKeyCell;
	uint currentlySelectingCell;
	uint allowsIncrementalSearching;
	uint tabKeyTraversesCellsExplicitlySet;
	uint tabKeyTraversesCells;
	uint drawingAncestor;
	uint autosizeCells;
	uint drawsBackground;
	uint drawsCellBackground;
	uint selectionByRect;
	uint autoscroll;
	uint allowEmptySel;
	uint listMode;
	uint radioMode;
	uint highlightMode;
}

class NSMatrix : NSControl, INSUserInterfaceValidations
{
	mixin (ObjcWrap);

	NSMatrix initWithFrame (NSRect frameRect)
	{
		id result = invokeObjcSelf!(id, "initWithFrame:", NSRect)(frameRect);
		return result is this.objcObject ? this : (result !is null ? new NSMatrix(result) : null);
	}

	this (NSRect frameRect)
	{
		super(NSMatrix.alloc.initWithFrame(frameRect).objcObject);
	}

	NSMatrix initWithFrame (NSRect frameRect, uint aMode, NSCell aCell, NSInteger rowsHigh, NSInteger colsWide)
	{
		id result = invokeObjcSelf!(id, "initWithFrame:mode:prototype:numberOfRows:numberOfColumns:", NSRect, uint, NSCell, NSInteger, NSInteger)(frameRect, aMode, aCell, rowsHigh, colsWide);
		return result is this.objcObject ? this : (result !is null ? new NSMatrix(result) : null);
	}

	this (NSRect frameRect, uint aMode, NSCell aCell, NSInteger rowsHigh, NSInteger colsWide)
	{
		super(NSMatrix.alloc.initWithFrame(frameRect, aMode, aCell, rowsHigh, colsWide).objcObject);
	}

	NSMatrix initWithFrame (NSRect frameRect, uint aMode, Class factoryId, NSInteger rowsHigh, NSInteger colsWide)
	{
		id result = invokeObjcSelf!(id, "initWithFrame:mode:cellClass:numberOfRows:numberOfColumns:", NSRect, uint, Class, NSInteger, NSInteger)(frameRect, aMode, factoryId, rowsHigh, colsWide);
		return result is this.objcObject ? this : (result !is null ? new NSMatrix(result) : null);
	}

	this (NSRect frameRect, uint aMode, Class factoryId, NSInteger rowsHigh, NSInteger colsWide)
	{
		super(NSMatrix.alloc.initWithFrame(frameRect, aMode, factoryId, rowsHigh, colsWide).objcObject);
	}

	void setCellClass (Class factoryId)
	{
		return invokeObjcSelf!(void, "setCellClass:", Class)(factoryId);
	}

	Class cellClass ()
	{
		return invokeObjcSelf!(Class, "cellClass");
	}

	Object prototype ()
	{
		return invokeObjcSelf!(Object, "prototype");
	}

	void setPrototype (NSCell aCell)
	{
		return invokeObjcSelf!(void, "setPrototype:", NSCell)(aCell);
	}

	NSCell makeCellAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(NSCell, "makeCellAtRow:column:", NSInteger, NSInteger)(row, col);
	}

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

	void setMode (uint aMode)
	{
		return invokeObjcSelf!(void, "setMode:", uint)(aMode);
	}

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

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

	void sendAction (SEL aSelector, Object anObject, bool flag)
	{
		return invokeObjcSelf!(void, "sendAction:to:forAllCells:", SEL, Object, bool)(aSelector, anObject, flag);
	}

	NSArray cells ()
	{
		return invokeObjcSelf!(NSArray, "cells");
	}

	void sortUsingSelector (SEL comparator)
	{
		return invokeObjcSelf!(void, "sortUsingSelector:", SEL)(comparator);
	}

	void sortUsingFunction (Comperator compare, void* context)
	{
		return invokeObjcSelf!(void, "sortUsingFunction:context:", Comperator, void*)(compare, context);
	}

	Object selectedCell ()
	{
		return invokeObjcSelf!(Object, "selectedCell");
	}

	NSArray selectedCells ()
	{
		return invokeObjcSelf!(NSArray, "selectedCells");
	}

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

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

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

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

	void setSelectionFrom (NSInteger startPos, NSInteger endPos, NSInteger anchorPos, bool lit)
	{
		return invokeObjcSelf!(void, "setSelectionFrom:to:anchor:highlight:", NSInteger, NSInteger, NSInteger, bool)(startPos, endPos, anchorPos, lit);
	}

	void deselectSelectedCell ()
	{
		return invokeObjcSelf!(void, "deselectSelectedCell");
	}

	void deselectAllCells ()
	{
		return invokeObjcSelf!(void, "deselectAllCells");
	}

	void selectCellAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(void, "selectCellAtRow:column:", NSInteger, NSInteger)(row, col);
	}

	void selectAll (Object sender)
	{
		return invokeObjcSelf!(void, "selectAll:", Object)(sender);
	}

	bool selectCellWithTag (NSInteger anInt)
	{
		return invokeObjcSelf!(bool, "selectCellWithTag:", NSInteger)(anInt);
	}

	NSSize cellSize ()
	{
		return invokeObjcSelf!(NSSize, "cellSize");
	}

	void setCellSize (NSSize aSize)
	{
		return invokeObjcSelf!(void, "setCellSize:", NSSize)(aSize);
	}

	NSSize intercellSpacing ()
	{
		return invokeObjcSelf!(NSSize, "intercellSpacing");
	}

	void setIntercellSpacing (NSSize aSize)
	{
		return invokeObjcSelf!(void, "setIntercellSpacing:", NSSize)(aSize);
	}

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

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

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

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

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

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

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

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

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

	void setState (NSInteger value, NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(void, "setState:atRow:column:", NSInteger, NSInteger, NSInteger)(value, row, col);
	}

	void getNumberOfRows (NSInteger* rowCount, NSInteger* colCount)
	{
		return invokeObjcSelf!(void, "getNumberOfRows:columns:", NSInteger*, NSInteger*)(rowCount, colCount);
	}

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

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

	Object cellAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(Object, "cellAtRow:column:", NSInteger, NSInteger)(row, col);
	}

	NSRect cellFrameAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(NSRect, "cellFrameAtRow:column:", NSInteger, NSInteger)(row, col);
	}

	bool getRow (NSInteger* row, NSInteger* col, NSCell aCell)
	{
		return invokeObjcSelf!(bool, "getRow:column:ofCell:", NSInteger*, NSInteger*, NSCell)(row, col, aCell);
	}

	bool getRow (NSInteger* row, NSInteger* col, NSPoint aPoint)
	{
		return invokeObjcSelf!(bool, "getRow:column:forPoint:", NSInteger*, NSInteger*, NSPoint)(row, col, aPoint);
	}

	void renewRows (NSInteger newRows, NSInteger newCols)
	{
		return invokeObjcSelf!(void, "renewRows:columns:", NSInteger, NSInteger)(newRows, newCols);
	}

	void putCell (NSCell newCell, NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(void, "putCell:atRow:column:", NSCell, NSInteger, NSInteger)(newCell, row, col);
	}

	void addRow ()
	{
		return invokeObjcSelf!(void, "addRow");
	}

	void addRowWithCells (NSArray newCells)
	{
		return invokeObjcSelf!(void, "addRowWithCells:", NSArray)(newCells);
	}

	void insertRow (NSInteger row)
	{
		return invokeObjcSelf!(void, "insertRow:", NSInteger)(row);
	}

	void insertRow (NSInteger row, NSArray newCells)
	{
		return invokeObjcSelf!(void, "insertRow:withCells:", NSInteger, NSArray)(row, newCells);
	}

	void removeRow (NSInteger row)
	{
		return invokeObjcSelf!(void, "removeRow:", NSInteger)(row);
	}

	void addColumn ()
	{
		return invokeObjcSelf!(void, "addColumn");
	}

	void addColumnWithCells (NSArray newCells)
	{
		return invokeObjcSelf!(void, "addColumnWithCells:", NSArray)(newCells);
	}

	void insertColumn (NSInteger column)
	{
		return invokeObjcSelf!(void, "insertColumn:", NSInteger)(column);
	}

	void insertColumn (NSInteger column, NSArray newCells)
	{
		return invokeObjcSelf!(void, "insertColumn:withCells:", NSInteger, NSArray)(column, newCells);
	}

	void removeColumn (NSInteger col)
	{
		return invokeObjcSelf!(void, "removeColumn:", NSInteger)(col);
	}

	Object cellWithTag (NSInteger anInt)
	{
		return invokeObjcSelf!(Object, "cellWithTag:", NSInteger)(anInt);
	}

	SEL doubleAction ()
	{
		return invokeObjcSelf!(SEL, "doubleAction");
	}

	void setDoubleAction (SEL aSelector)
	{
		return invokeObjcSelf!(void, "setDoubleAction:", SEL)(aSelector);
	}

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

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

	void sizeToCells ()
	{
		return invokeObjcSelf!(void, "sizeToCells");
	}

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

	void drawCellAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(void, "drawCellAtRow:column:", NSInteger, NSInteger)(row, col);
	}

	void highlightCell (bool flag, NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(void, "highlightCell:atRow:column:", bool, NSInteger, NSInteger)(flag, row, col);
	}

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

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

	void scrollCellToVisibleAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(void, "scrollCellToVisibleAtRow:column:", NSInteger, NSInteger)(row, col);
	}

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

	void mouseDown (NSEvent theEvent)
	{
		return invokeObjcSelf!(void, "mouseDown:", NSEvent)(theEvent);
	}

	bool performKeyEquivalent (NSEvent theEvent)
	{
		return invokeObjcSelf!(bool, "performKeyEquivalent:", NSEvent)(theEvent);
	}

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

	void sendDoubleAction ()
	{
		return invokeObjcSelf!(void, "sendDoubleAction");
	}

	Object delegate_ ()
	{
		return invokeObjcSelf!(Object, "delegate");
	}

	void setDelegate (Object anObject)
	{
		return invokeObjcSelf!(void, "setDelegate:", Object)(anObject);
	}

	bool textShouldBeginEditing (NSText textObject)
	{
		return invokeObjcSelf!(bool, "textShouldBeginEditing:", NSText)(textObject);
	}

	bool textShouldEndEditing (NSText textObject)
	{
		return invokeObjcSelf!(bool, "textShouldEndEditing:", NSText)(textObject);
	}

	void textDidBeginEditing (NSNotification notification)
	{
		return invokeObjcSelf!(void, "textDidBeginEditing:", NSNotification)(notification);
	}

	void textDidEndEditing (NSNotification notification)
	{
		return invokeObjcSelf!(void, "textDidEndEditing:", NSNotification)(notification);
	}

	void textDidChange (NSNotification notification)
	{
		return invokeObjcSelf!(void, "textDidChange:", NSNotification)(notification);
	}

	void selectText (Object sender)
	{
		return invokeObjcSelf!(void, "selectText:", Object)(sender);
	}

	Object selectTextAtRow (NSInteger row, NSInteger col)
	{
		return invokeObjcSelf!(Object, "selectTextAtRow:column:", NSInteger, NSInteger)(row, col);
	}

	bool acceptsFirstMouse (NSEvent theEvent)
	{
		return invokeObjcSelf!(bool, "acceptsFirstMouse:", NSEvent)(theEvent);
	}

	void resetCursorRects ()
	{
		return invokeObjcSelf!(void, "resetCursorRects");
	}

	void setToolTip (NSString toolTipString, NSCell cell)
	{
		return invokeObjcSelf!(void, "setToolTip:forCell:", NSString, NSCell)(toolTipString, cell);
	}

	NSString toolTipForCell (NSCell cell)
	{
		return invokeObjcSelf!(NSString, "toolTipForCell:", NSCell)(cell);
	}

	bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem)
	{
		return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem);
	}
}