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

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;



enum NSSpeechBoundar : NSUInteger
{
    NSSpeechImmediateBoundary = 0,
    NSSpeechWordBoundary,
    NSSpeechSentenceBoundary
}

alias NSSpeechBoundar.NSSpeechImmediateBoundary NSSpeechImmediateBoundary;
alias NSSpeechBoundar.NSSpeechWordBoundary NSSpeechWordBoundary;
alias NSSpeechBoundar.NSSpeechSentenceBoundary NSSpeechSentenceBoundary;



public class NSSpeechSynthesizer : NSObject
{

    public this ()
    {
        super();
    }

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

    public void addSpeechDictionary (NSDictionary speechDictionary)
    {
        OS.objc_msgSend(this.id_, OS.sel_addSpeechDictionary_1, speechDictionary !is null ? speechDictionary.id_ : null);
    }

    public static NSDictionary attributesForVoice (NSString voice)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_attributesForVoice_1, voice !is null ? voice.id_ : null);
        return result !is null ? new NSDictionary(result) : null;
    }

    public static NSArray availableVoices ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_availableVoices);
        return result !is null ? new NSArray(result) : null;
    }

    public void continueSpeaking ()
    {
        OS.objc_msgSend(this.id_, OS.sel_continueSpeaking);
    }

    public static NSString defaultVoice ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_defaultVoice);
        return result !is null ? new NSString(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 id initWithVoice (NSString voice)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithVoice_1, voice !is null ? voice.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static bool isAnyApplicationSpeaking ()
    {
        return OS.objc_msgSend(OS.class_NSSpeechSynthesizer, OS.sel_isAnyApplicationSpeaking) !is null;
    }

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

    public id objectForProperty (NSString property, objc.id** outError)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectForProperty_1error_1, property !is null ? property.id_ : null, outError);
        return result !is null ? new id(result) : null;
    }

    public void pauseSpeakingAtBoundary (NSSpeechBoundar boundary)
    {
        OS.objc_msgSend(this.id_, OS.sel_pauseSpeakingAtBoundary_1, boundary);
    }

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

    public float rate ()
    {
        return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_rate);
    }

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

    public bool setObject (id object, NSString property, objc.id** outError)
    {
        return OS.objc_msgSend(this.id_, OS.sel_setObject_1forProperty_1error_1, object !is null ? object.id_ : null,
                property !is null ? property.id_ : null, outError) !is null;
    }

    public void setRate (float rate)
    {
        OS.objc_msgSend(this.id_, OS.sel_setRate_1, rate);
    }

    public void setUsesFeedbackWindow (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setUsesFeedbackWindow_1, flag);
    }

    public bool setVoice (NSString voice)
    {
        return OS.objc_msgSend(this.id_, OS.sel_setVoice_1, voice !is null ? voice.id_ : null) !is null;
    }

    public void setVolume (float volume)
    {
        OS.objc_msgSend(this.id_, OS.sel_setVolume_1, volume);
    }

    public bool startSpeakingString_ (NSString string)
    {
        return OS.objc_msgSend(this.id_, OS.sel_startSpeakingString_1, string !is null ? string.id_ : null) !is null;
    }

    public bool startSpeakingString_toURL_ (NSString string, NSURL url)
    {
        return OS.objc_msgSend(this.id_, OS.sel_startSpeakingString_1toURL_1, string !is null ? string.id_ : null, url !is null ? url.id_ : null) !is null;
    }

    public void stopSpeaking ()
    {
        OS.objc_msgSend(this.id_, OS.sel_stopSpeaking);
    }

    public void stopSpeakingAtBoundary (NSSpeechBoundar boundary)
    {
        OS.objc_msgSend(this.id_, OS.sel_stopSpeakingAtBoundary_1, boundary);
    }

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

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

    public float volume ()
    {
        return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_volume);
    }

}