view dwt/internal/cocoa/NSMatrix.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
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.NSMatrix;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSControl;
import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSNotification;
import dwt.internal.cocoa.NSPoint;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSText;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

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

alias NSMatrixMode.NSRadioModeMatrix NSRadioModeMatrix;
alias NSMatrixMode.NSHighlightModeMatrix NSHighlightModeMatrix;
alias NSMatrixMode.NSListModeMatrix NSListModeMatrix;
alias NSMatrixMode.NSTrackModeMatrix NSTrackModeMatrix;

public class NSMatrix : NSControl
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public bool acceptsFirstMouse (NSEvent theEvent)
    {
        return OS.objc_msgSend(this.id_, OS.sel_acceptsFirstMouse_1, theEvent !is null ? theEvent.id_ : null) !is null;
    }

    public void addColumn ()
    {
        OS.objc_msgSend(this.id_, OS.sel_addColumn);
    }

    public void addColumnWithCells (NSArray newCells)
    {
        OS.objc_msgSend(this.id_, OS.sel_addColumnWithCells_1, newCells !is null ? newCells.id_ : null);
    }

    public void addRow ()
    {
        OS.objc_msgSend(this.id_, OS.sel_addRow);
    }

    public void addRowWithCells (NSArray newCells)
    {
        OS.objc_msgSend(this.id_, OS.sel_addRowWithCells_1, newCells !is null ? newCells.id_ : null);
    }

    public bool allowsEmptySelection ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_allowsEmptySelection) !is null;
    }

    public bool autosizesCells ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_autosizesCells) !is null;
    }

    public NSColor backgroundColor ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor);
        return result !is null ? new NSColor(result) : null;
    }

    public id cellAtRow (NSInteger row, NSInteger col)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_cellAtRow_1column_1, row, col);
        return result !is null ? new id(result) : null;
    }

    public NSColor cellBackgroundColor ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_cellBackgroundColor);
        return result !is null ? new NSColor(result) : null;
    }

    //public objc.Class cellClass() {
    //  return OS.objc_msgSend(this.id_, OS.sel_cellClass);
    //}

    public NSRect cellFrameAtRow (NSInteger row, NSInteger col)
    {
        NSRect result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_cellFrameAtRow_1column_1, row, col);
        return result;
    }

    public NSSize cellSize ()
    {
        NSSize result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_cellSize);
        return result;
    }

    public id cellWithTag (NSInteger anInt)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_cellWithTag_1, anInt);
        return result !is null ? new id(result) : null;
    }

    public NSArray cells ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_cells);
        return result !is null ? new NSArray(result) : null;
    }

    public id delegatee ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
        return result !is null ? new id(result) : null;
    }

    public void deselectAllCells ()
    {
        OS.objc_msgSend(this.id_, OS.sel_deselectAllCells);
    }

    public void deselectSelectedCell ()
    {
        OS.objc_msgSend(this.id_, OS.sel_deselectSelectedCell);
    }

    public objc.SEL doubleAction ()
    {
        return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_doubleAction);
    }

    public void drawCellAtRow (NSInteger row, NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_drawCellAtRow_1column_1, row, col);
    }

    public bool drawsBackground ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_drawsBackground) !is null;
    }

    public bool drawsCellBackground ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_drawsCellBackground) !is null;
    }

    public void getNumberOfRows (NSInteger* rowCount, NSInteger* colCount)
    {
        OS.objc_msgSend(this.id_, OS.sel_getNumberOfRows_1columns_1, rowCount, colCount);
    }

    public bool getRow_column_forPoint_ (NSInteger* row, NSInteger* col, NSPoint aPoint)
    {
        return OS.objc_msgSend(this.id_, OS.sel_getRow_1column_1forPoint_1, row, col, aPoint) !is null;
    }

    public bool getRow_column_ofCell_ (NSInteger* row, NSInteger* col, NSCell aCell)
    {
        return OS.objc_msgSend(this.id_, OS.sel_getRow_1column_1ofCell_1, row, col, aCell !is null ? aCell.id_ : null) !is null;
    }

    public void highlightCell (bool flag, NSInteger row, NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_highlightCell_1atRow_1column_1, flag, row, col);
    }

    public id initWithFrame_ (NSRect frameRect)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFrame_1, frameRect);
        return result !is null ? new id(result) : null;
    }

    public id initWithFrame_mode_cellClass_numberOfRows_numberOfColumns_ (NSRect frameRect, NSInteger aMode, objc.Class factoryId,
            NSInteger rowsHigh, NSInteger colsWide)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFrame_1mode_1cellClass_1numberOfRows_1numberOfColumns_1, frameRect, aMode,
                factoryId, rowsHigh, colsWide);
        return result !is null ? new id(result) : null;
    }

    public id initWithFrame_mode_prototype_numberOfRows_numberOfColumns_ (NSRect frameRect, NSInteger aMode, NSCell aCell, NSInteger rowsHigh,
            NSInteger colsWide)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFrame_1mode_1prototype_1numberOfRows_1numberOfColumns_1, frameRect, aMode,
                aCell !is null ? aCell.id_ : null, rowsHigh, colsWide);
        return result !is null ? new id(result) : null;
    }

    public void insertColumn_ (NSInteger column)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertColumn_1, column);
    }

    public void insertColumn_withCells_ (NSInteger column, NSArray newCells)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertColumn_1withCells_1, column, newCells !is null ? newCells.id_ : null);
    }

    public void insertRow_ (NSInteger row)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertRow_1, row);
    }

    public void insertRow_withCells_ (NSInteger row, NSArray newCells)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertRow_1withCells_1, row, newCells !is null ? newCells.id_ : null);
    }

    public NSSize intercellSpacing ()
    {
        NSSize result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_intercellSpacing);
        return result;
    }

    public bool isAutoscroll ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isAutoscroll) !is null;
    }

    public bool isSelectionByRect ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isSelectionByRect) !is null;
    }

    public id keyCell ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyCell);
        return result !is null ? new id(result) : null;
    }

    public NSCell makeCellAtRow (NSInteger row, NSInteger col)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_makeCellAtRow_1column_1, row, col);
        return result !is null ? new NSCell(result) : null;
    }

    public NSMatrixMode mode ()
    {
        return cast(NSMatrixMode) OS.objc_msgSend(this.id_, OS.sel_mode);
    }

    public void mouseDown (NSEvent theEvent)
    {
        OS.objc_msgSend(this.id_, OS.sel_mouseDown_1, theEvent !is null ? theEvent.id_ : null);
    }

    public NSInteger mouseDownFlags ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_mouseDownFlags);
    }

    public NSInteger numberOfColumns ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfColumns);
    }

    public NSInteger numberOfRows ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfRows);
    }

    public bool performKeyEquivalent (NSEvent theEvent)
    {
        return OS.objc_msgSend(this.id_, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id_ : null) !is null;
    }

    public id prototype ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_prototype);
        return result !is null ? new id(result) : null;
    }

    public void putCell (NSCell newCell, NSInteger row, NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_putCell_1atRow_1column_1, newCell !is null ? newCell.id_ : null, row, col);
    }

    public void removeColumn (NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeColumn_1, col);
    }

    public void removeRow (NSInteger row)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeRow_1, row);
    }

    public void renewRows (NSInteger newRows, NSInteger newCols)
    {
        OS.objc_msgSend(this.id_, OS.sel_renewRows_1columns_1, newRows, newCols);
    }

    public void resetCursorRects ()
    {
        OS.objc_msgSend(this.id_, OS.sel_resetCursorRects);
    }

    public void scrollCellToVisibleAtRow (NSInteger row, NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_scrollCellToVisibleAtRow_1column_1, row, col);
    }

    public void selectAll (id sender)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectAll_1, sender !is null ? sender.id_ : null);
    }

    public void selectCellAtRow (NSInteger row, NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectCellAtRow_1column_1, row, col);
    }

    public bool selectCellWithTag (NSInteger anInt)
    {
        return OS.objc_msgSend(this.id_, OS.sel_selectCellWithTag_1, anInt) !is null;
    }

    public void selectText (id sender)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectText_1, sender !is null ? sender.id_ : null);
    }

    public id selectTextAtRow (NSInteger row, NSInteger col)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectTextAtRow_1column_1, row, col);
        return result !is null ? new id(result) : null;
    }

    public id selectedCell ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCell);
        return result !is null ? new id(result) : null;
    }

    public NSArray selectedCells ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedCells);
        return result !is null ? new NSArray(result) : null;
    }

    public NSInteger selectedColumn ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedColumn);
    }

    public NSInteger selectedRow ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_selectedRow);
    }

    public bool sendAction ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_sendAction) !is null;
    }

    public void sendAction_to_forAllCells_ (objc.SEL aSelector, id anObject, bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_sendAction_1to_1forAllCells_1, aSelector, anObject !is null ? anObject.id_ : null, flag);
    }

    public void sendDoubleAction ()
    {
        OS.objc_msgSend(this.id_, OS.sel_sendDoubleAction);
    }

    public void setAllowsEmptySelection (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAllowsEmptySelection_1, flag);
    }

    public void setAutoscroll (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAutoscroll_1, flag);
    }

    public void setAutosizesCells (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAutosizesCells_1, flag);
    }

    public void setBackgroundColor (NSColor color)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null);
    }

    public void setCellBackgroundColor (NSColor color)
    {
        OS.objc_msgSend(this.id_, OS.sel_setCellBackgroundColor_1, color !is null ? color.id_ : null);
    }

    //public void setCellClass(objc.Class factoryId) {
    //  OS.objc_msgSend(this.id_, OS.sel_setCellClass_1, factoryId);
    //}

    public void setCellSize (NSSize aSize)
    {
        OS.objc_msgSend(this.id_, OS.sel_setCellSize_1, aSize);
    }

    public void setDelegate (id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
    }

    public void setDoubleAction (objc.SEL aSelector)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDoubleAction_1, aSelector);
    }

    public void setDrawsBackground (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDrawsBackground_1, flag);
    }

    public void setDrawsCellBackground (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDrawsCellBackground_1, flag);
    }

    public void setIntercellSpacing (NSSize aSize)
    {
        OS.objc_msgSend(this.id_, OS.sel_setIntercellSpacing_1, aSize);
    }

    public void setKeyCell (NSCell keyCell)
    {
        OS.objc_msgSend(this.id_, OS.sel_setKeyCell_1, keyCell !is null ? keyCell.id_ : null);
    }

    public void setMode (NSMatrixMode aMode)
    {
        OS.objc_msgSend(this.id_, OS.sel_setMode_1, aMode);
    }

    public void setPrototype (NSCell aCell)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPrototype_1, aCell !is null ? aCell.id_ : null);
    }

    public void setScrollable (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setScrollable_1, flag);
    }

    public void setSelectionByRect (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setSelectionByRect_1, flag);
    }

    public void setSelectionFrom (NSInteger startPos, NSInteger endPos, NSInteger anchorPos, bool lit)
    {
        OS.objc_msgSend(this.id_, OS.sel_setSelectionFrom_1to_1anchor_1highlight_1, startPos, endPos, anchorPos, lit);
    }

    public void setState (NSInteger value, NSInteger row, NSInteger col)
    {
        OS.objc_msgSend(this.id_, OS.sel_setState_1atRow_1column_1, value, row, col);
    }

    public void setTabKeyTraversesCells (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTabKeyTraversesCells_1, flag);
    }

    public void setToolTip (NSString toolTipString, NSCell cell)
    {
        OS.objc_msgSend(this.id_, OS.sel_setToolTip_1forCell_1, toolTipString !is null ? toolTipString.id_ : null, cell !is null ? cell.id_ : null);
    }

    public void setValidateSize (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setValidateSize_1, flag);
    }

    public void sizeToCells ()
    {
        OS.objc_msgSend(this.id_, OS.sel_sizeToCells);
    }

    public void sortUsingFunction (int* function(objc.id, objc.id, void*) compare, void* context)
    {
        OS.objc_msgSend(this.id_, OS.sel_sortUsingFunction_1context_1, compare, context);
    }

    public void sortUsingSelector (objc.SEL comparator)
    {
        OS.objc_msgSend(this.id_, OS.sel_sortUsingSelector_1, comparator);
    }

    public bool tabKeyTraversesCells ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_tabKeyTraversesCells) !is null;
    }

    public void textDidBeginEditing (NSNotification notification)
    {
        OS.objc_msgSend(this.id_, OS.sel_textDidBeginEditing_1, notification !is null ? notification.id_ : null);
    }

    public void textDidChange (NSNotification notification)
    {
        OS.objc_msgSend(this.id_, OS.sel_textDidChange_1, notification !is null ? notification.id_ : null);
    }

    public void textDidEndEditing (NSNotification notification)
    {
        OS.objc_msgSend(this.id_, OS.sel_textDidEndEditing_1, notification !is null ? notification.id_ : null);
    }

    public bool textShouldBeginEditing (NSText textObject)
    {
        return OS.objc_msgSend(this.id_, OS.sel_textShouldBeginEditing_1, textObject !is null ? textObject.id_ : null) !is null;
    }

    public bool textShouldEndEditing (NSText textObject)
    {
        return OS.objc_msgSend(this.id_, OS.sel_textShouldEndEditing_1, textObject !is null ? textObject.id_ : null) !is null;
    }

    public NSString toolTipForCell (NSCell cell)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_toolTipForCell_1, cell !is null ? cell.id_ : null);
        return result !is null ? new NSString(result) : null;
    }

}