view dwt/internal/cocoa/NSResponder.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 d8635bb48c7c
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.NSResponder;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSError;
import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSInterfaceStyle;
import dwt.internal.cocoa.NSMenu;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSUndoManager;
import dwt.internal.cocoa.NSWindow;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSResponder : NSObject
{

    public this ()
    {
        super();
    }

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

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

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

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

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

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

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

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

    public void cursorUpdate (NSEvent event)
    {
        OS.objc_msgSend(this.id_, OS.sel_cursorUpdate_1, event !is null ? event.id_ : null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

    public void flushBufferedKeyEvents ()
    {
        OS.objc_msgSend(this.id_, OS.sel_flushBufferedKeyEvents);
    }

    public void helpRequested (NSEvent eventPtr)
    {
        OS.objc_msgSend(this.id_, OS.sel_helpRequested_1, eventPtr !is null ? eventPtr.id_ : null);
    }

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

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

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

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

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

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

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

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

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

    public void insertText (id insertString)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertText_1, insertString !is null ? insertString.id_ : null);
    }

    public NSInterfaceStyle interfaceStyle ()
    {
        return cast(NSInterfaceStyle) OS.objc_msgSend(this.id_, OS.sel_interfaceStyle);
    }

    public void interpretKeyEvents (NSArray eventArray)
    {
        OS.objc_msgSend(this.id_, OS.sel_interpretKeyEvents_1, eventArray !is null ? eventArray.id_ : null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public void noResponderFor (objc.SEL eventSelector)
    {
        OS.objc_msgSend(this.id_, OS.sel_noResponderFor_1, eventSelector);
    }

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

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

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

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

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

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

    public bool performMnemonic (NSString theString)
    {
        return OS.objc_msgSend(this.id_, OS.sel_performMnemonic_1, theString !is null ? theString.id_ : null) !is null;
    }

    public bool presentError_ (NSError error)
    {
        return OS.objc_msgSend(this.id_, OS.sel_presentError_1, error !is null ? error.id_ : null) !is null;
    }

    public void presentError_modalForWindow_delegate_didPresentSelector_contextInfo_ (NSError error, NSWindow window, id delegatee,
            objc.SEL didPresentSelector, void* contextInfo)
    {
        OS.objc_msgSend(this.id_, OS.sel_presentError_1modalForWindow_1delegate_1didPresentSelector_1contextInfo_1, error !is null ? error.id_ : null,
                window !is null ? window.id_ : null, delegatee !is null ? delegatee.id_ : null, didPresentSelector, contextInfo);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public void setInterfaceStyle (NSInterfaceStyle interfaceStyle)
    {
        OS.objc_msgSend(this.id_, OS.sel_setInterfaceStyle_1, interfaceStyle);
    }

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

    public void setMenu (NSMenu menu)
    {
        OS.objc_msgSend(this.id_, OS.sel_setMenu_1, menu !is null ? menu.id_ : null);
    }

    public void setNextResponder (NSResponder aResponder)
    {
        OS.objc_msgSend(this.id_, OS.sel_setNextResponder_1, aResponder !is null ? aResponder.id_ : null);
    }

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

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

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

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

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

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

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

    public bool tryToPerform (objc.SEL anAction, id anObject)
    {
        return OS.objc_msgSend(this.id_, OS.sel_tryToPerform_1with_1, anAction, anObject !is null ? anObject.id_ : null) !is null;
    }

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

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

    public id validRequestorForSendType (NSString sendType, NSString returnType)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_validRequestorForSendType_1returnType_1, sendType !is null ? sendType.id_ : null,
                returnType !is null ? returnType.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public NSError willPresentError (NSError error)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_willPresentError_1, error !is null ? error.id_ : null);
        return result !is null ? new NSError(result) : null;
    }

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

}