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

import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSPanel;
import dwt.internal.cocoa.NSRange;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSSpellChecker : NSObject
{

    public this ()
    {
        super();
    }

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

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

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

    public NSRange checkGrammarOfString (NSString stringToCheck, NSInteger startingOffset, NSString language, bool wrapFlag, NSInteger tag, /*NSArray** */objc.id** details)
    {
        NSRange result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_checkGrammarOfString_1startingAt_1language_1wrap_1inSpellDocumentWithTag_1details_1,
                stringToCheck !is null ? stringToCheck.id_ : null, startingOffset, language !is null ? language.id_ : null, wrapFlag, tag, details);
        return result;
    }

    public NSRange checkSpellingOfString_startingAt_ (NSString stringToCheck, NSInteger startingOffset)
    {
        NSRange result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_checkSpellingOfString_1startingAt_1, stringToCheck !is null ? stringToCheck.id_ : null,
                startingOffset);
        return result;
    }

    public NSRange checkSpellingOfString_startingAt_language_wrap_inSpellDocumentWithTag_wordCount_ (NSString stringToCheck, NSInteger startingOffset,
            NSString language, bool wrapFlag, NSInteger tag, NSInteger* wordCount)
    {
        NSRange result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_checkSpellingOfString_1startingAt_1language_1wrap_1inSpellDocumentWithTag_1wordCount_1,
                stringToCheck !is null ? stringToCheck.id_ : null, startingOffset, language !is null ? language.id_ : null, wrapFlag, tag, wordCount);
        return result;
    }

    public void closeSpellDocumentWithTag (NSInteger tag)
    {
        OS.objc_msgSend(this.id_, OS.sel_closeSpellDocumentWithTag_1, tag);
    }

    public NSArray completionsForPartialWordRange (NSRange range, NSString string, NSString language, NSInteger tag)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_completionsForPartialWordRange_1inString_1language_1inSpellDocumentWithTag_1, range,
                string !is null ? string.id_ : null, language !is null ? language.id_ : null, tag);
        return result !is null ? new NSArray(result) : null;
    }

    public NSInteger countWordsInString (NSString stringToCount, NSString language)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_countWordsInString_1language_1, stringToCount !is null ? stringToCount.id_ : null,
                language !is null ? language.id_ : null);
    }

    public void forgetWord (NSString word)
    {
        OS.objc_msgSend(this.id_, OS.sel_forgetWord_1, word !is null ? word.id_ : null);
    }

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

    public bool hasLearnedWord (NSString word)
    {
        return OS.objc_msgSend(this.id_, OS.sel_hasLearnedWord_1, word !is null ? word.id_ : null) !is null;
    }

    public void ignoreWord (NSString wordToIgnore, NSInteger tag)
    {
        OS.objc_msgSend(this.id_, OS.sel_ignoreWord_1inSpellDocumentWithTag_1, wordToIgnore !is null ? wordToIgnore.id_ : null, tag);
    }

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

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

    public void learnWord (NSString word)
    {
        OS.objc_msgSend(this.id_, OS.sel_learnWord_1, word !is null ? word.id_ : null);
    }

    public void setAccessoryView (NSView aView)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAccessoryView_1, aView !is null ? aView.id_ : null);
    }

    public void setIgnoredWords (NSArray words, NSInteger tag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setIgnoredWords_1inSpellDocumentWithTag_1, words !is null ? words.id_ : null, tag);
    }

    public bool setLanguage (NSString language)
    {
        return OS.objc_msgSend(this.id_, OS.sel_setLanguage_1, language !is null ? language.id_ : null) !is null;
    }

    public void setWordFieldStringValue (NSString aString)
    {
        OS.objc_msgSend(this.id_, OS.sel_setWordFieldStringValue_1, aString !is null ? aString.id_ : null);
    }

    public static NSSpellChecker sharedSpellChecker ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSSpellChecker, OS.sel_sharedSpellChecker);
        return result !is null ? new NSSpellChecker(result) : null;
    }

    public static bool sharedSpellCheckerExists ()
    {
        return OS.objc_msgSend(OS.class_NSSpellChecker, OS.sel_sharedSpellCheckerExists) !is null;
    }

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

    public static NSInteger uniqueSpellDocumentTag ()
    {
        return cast(NSInteger) OS.objc_msgSend(OS.class_NSSpellChecker, OS.sel_uniqueSpellDocumentTag);
    }

    public void unlearnWord (NSString word)
    {
        OS.objc_msgSend(this.id_, OS.sel_unlearnWord_1, word !is null ? word.id_ : null);
    }

    public void updateSpellingPanelWithGrammarString (NSString string, NSDictionary detail)
    {
        OS.objc_msgSend(this.id_, OS.sel_updateSpellingPanelWithGrammarString_1detail_1, string !is null ? string.id_ : null,
                detail !is null ? detail.id_ : null);
    }

    public void updateSpellingPanelWithMisspelledWord (NSString word)
    {
        OS.objc_msgSend(this.id_, OS.sel_updateSpellingPanelWithMisspelledWord_1, word !is null ? word.id_ : null);
    }

}