#ifndef DO_NO_IMPORTS
import "oaidl.idl";
import "msctf.idl";
import "ctfutb.idl";
#endif

typedef enum
{
    STYLE_ACTIVE_SELECTION = 0,
    STYLE_IMPLIED_SELECTION = 0x1
} TfIntegratableCandidateListSelectionStyle;

typedef enum
{
    GETIF_RESMGR = 0,
    GETIF_RECOCONTEXT = 0x1,
    GETIF_RECOGNIZER = 0x2,
    GETIF_VOICE = 0x3,
    GETIF_DICTGRAM = 0x4,
    GETIF_RECOGNIZERNOINIT = 0x5
} TfSapiObject;

typedef struct TF_LMLATTELEMENT
{
    DWORD dwFrameStart;
    DWORD dwFrameLen;
    DWORD dwFlags;
    union {
        INT iCost;
    };
    BSTR  bstrText;
} TF_LMLATTELEMENT;

cpp_quote("EXTERN_C const CLSID CLSID_SapiLayr;")

interface IEnumTfCandidates;
interface IEnumTfLatticeElements;
interface ITfCandidateList;
interface ITfCandidateString;
interface ITfFnAdviseText;
interface ITfFnBalloon;
interface ITfFnConfigure;
interface ITfFnConfigureRegisterEudc;
interface ITfFnConfigureRegisterWord;
interface ITfFnGetLinguisticAlternates;
interface ITfFnGetPreferredTouchKeyboardLayout;
interface ITfFnGetSAPIObject;
interface ITfFnLMInternal;
interface ITfFnLMProcessor;
interface ITfFnLangProfileUtil;
interface ITfFnPlayBack;
interface ITfFnPropertyUIStatus;
interface ITfFnReconversion;
interface ITfFnSearchCandidateProvider;
interface ITfFnShowHelp;
interface ITfFunction;
interface ITfIntegratableCandidateListUIElement;
interface ITfLMLattice;
interface IUIManagerEventSink;

[
  object,
  uuid(defb1926-6c80-4ce8-87d4-d6b72b812bde),
  pointer_default(unique)
]
interface IEnumTfCandidates : IUnknown
{
    HRESULT Clone(
        [out] IEnumTfCandidates **ppEnum);

    HRESULT Next(
        [in]  ULONG              ulCount,
        [out] ITfCandidateString **ppCand,
        [out] ULONG              *pcFetched);

    HRESULT Reset(void);

    HRESULT Skip(
        [in] ULONG ulCount);
}

[
  object,
  uuid(56988052-47da-4a05-911a-e3d941f17145),
  pointer_default(unique)
]
interface IEnumTfLatticeElements : IUnknown
{
    HRESULT Clone(
        [out] IEnumTfLatticeElements **ppEnum);

    HRESULT Next(
        [in]  ULONG            ulCount,
        [out] TF_LMLATTELEMENT *rgsElements,
        [out] ULONG            *pcFetched);

    HRESULT Reset(void);

    HRESULT Skip(
        [in] ULONG ulCount);
}

[
  object,
  uuid(a3ad50fb-9bdb-49e3-a843-6c76520fbf5d),
  pointer_default(unique)
]
interface ITfCandidateList : IUnknown
{
    typedef enum
    {
        CAND_FINALIZED = 0,
        CAND_SELECTED = 0x1,
        CAND_CANCELED = 0x2
    } TfCandidateResult;

    HRESULT EnumCandidates(
        [out] IEnumTfCandidates **ppEnum);

    HRESULT GetCandidate(
        [in]  ULONG              nIndex,
        [out] ITfCandidateString **ppCand);

    HRESULT GetCandidateNum(
        [out] ULONG *pnCnt);

    HRESULT SetResult(
        [in] ULONG             nIndex,
        [in] TfCandidateResult imcr);
}

[
  object,
  uuid(581f317e-fd9d-443f-b972-ed00467c5d40),
  pointer_default(unique)
]
interface ITfCandidateString : IUnknown
{
    HRESULT GetString(
        [out] BSTR *pbstr);

    HRESULT GetIndex(
        [out] ULONG *pnIndex);
}

[
  object,
  uuid(3527268b-7d53-4dd9-92b7-7296ae461249),
  pointer_default(unique)
]
interface ITfFnAdviseText : IUnknown
{
    HRESULT OnTextUpdate(
        [in] ITfRange    *pRange,
        [in] const WCHAR *pchText,
        [in] LONG        cch);

    HRESULT OnLatticeUpdate(
        [in] ITfRange     *pRange,
        [in] ITfLMLattice *pLattice);
}

[
  object,
  uuid(3bab89e4-5fbe-45f4-a5bc-dca36ad225a8),
  pointer_default(unique)
]
interface ITfFnBalloon : IUnknown
{
    HRESULT UpdateBalloon(
        [in] TfLBBalloonStyle style,
        [in] const WCHAR      *pch,
        [in] ULONG            cch);
}

[
  object,
  uuid(88f567c6-1757-49f8-a1b2-89234c1eeff9),
  pointer_default(unique)
]
interface ITfFnConfigure : IUnknown
{
    HRESULT Show(
        [in] HWND    hwndParent,
        [in] LANGID  langid,
        [in] REFGUID rguidProfile);
}

[
  object,
  uuid(b5e26ff5-d7ad-4304-913f-21a2ed95a1b0),
  pointer_default(unique)
]
interface ITfFnConfigureRegisterEudc : IUnknown
{
    HRESULT Show(
        [in] HWND    hwndParent,
        [in] LANGID  langid,
        [in] REFGUID rguidProfile,
             BSTR    bstrRegistered);
}

[
  object,
  uuid(bb95808a-6d8f-4bca-8400-5390b586aedf),
  pointer_default(unique)
]
interface ITfFnConfigureRegisterWord : IUnknown
{
    HRESULT Show(
        [in] HWND    hwndParent,
        [in] LANGID  langid,
        [in] REFGUID rguidProfile,
        [in] BSTR    bstrRegistered);
}

[
  object,
  uuid(db593490-098f-11d3-8df0-00105a2799b5),
  pointer_default(unique)
]
interface ITfFunction : IUnknown
{
    HRESULT GetDisplayName(
        [out] BSTR *pbstrName);
}

[
  object,
  uuid(ea163ce2-7a65-4506-82a3-c528215da64e),
  pointer_default(unique)
]
interface ITfFnGetLinguisticAlternates : ITfFunction
{
    HRESULT GetAlternates(
        [in]  ITfRange         *pRange,
        [out] ITfCandidateList **ppCandidateList);
}

[
  object,
  uuid(5f309a41-590a-4acc-a97f-d8efff13fdfc),
  pointer_default(unique)
]
interface ITfFnGetPreferredTouchKeyboardLayout : ITfFunction
{
    typedef enum
    {
        TKBLT_UNDEFINED = 0,
        TKBLT_CLASSIC = 1,
        TKBLT_OPTIMIZED = 2
    } TKBLayoutType;

    HRESULT GetLayout(
        [out] TKBLayoutType *pTKBLayoutType,
        [out] WORD          *pwPreferredLayoutId);
}

[
  object,
  uuid(5c0ab7ea-167d-4f59-bfb5-4693755e90ca),
  pointer_default(unique)
]
interface ITfFnGetSAPIObject : IUnknown
{
    HRESULT Get(
        [in]  TfSapiObject sObj,
        [out] IUnknown     **ppunk);
}

[
  object,
  uuid(04b825b1-ac9a-4f7b-b5ad-c7168f1ee445),
  pointer_default(unique)
]
interface ITfFnLMInternal : IUnknown
{
    HRESULT ProcessLattice(
        [in] ITfRange *pRange);
}

[
  object,
  uuid(7afbf8e7-ac4b-4082-b058-890899d3a010),
  pointer_default(unique)
]
interface ITfFnLMProcessor : IUnknown
{
    HRESULT QueryRange(
        [in]  ITfRange *pRange,
        [out] ITfRange **ppNewRange,
        [out] BOOL     *pfAccepted);

    HRESULT QueryLangID(
        [in]  LANGID langid,
        [out] BOOL   *pfAccepted);

    HRESULT GetReconversion(
        [in]  ITfRange         *pRange,
        [out] ITfCandidateList **ppCandList);

    HRESULT Reconvert(
        [in] ITfRange *pRange);

    HRESULT QueryKey(
        [in]  BOOL   fUp,
        [in]  WPARAM vKey,
        [in]  LPARAM lparamKeydata,
        [out] BOOL   *pfInterested);

    HRESULT InvokeKey(
        [in] BOOL   fUp,
        [in] WPARAM vKey,
        [in] LPARAM lparamKeyData);

    HRESULT InvokeFunc(
        [in] ITfContext *pic,
        [in] REFGUID    refguidFunc);
}

[
  object,
  uuid(a87a8574-a6c1-4e15-99f0-3d3965f548eb),
  pointer_default(unique)
]
interface ITfFnLangProfileUtil : IUnknown
{
    HRESULT RegisterActiveProfiles(void);

    HRESULT IsProfileAvailableForLang(
        [in]  LANGID langid,
        [out] BOOL   *pfAvailable);
}

[
  object,
  uuid(a3a416a4-0f64-11d3-b5b7-00c04fc324a1),
  pointer_default(unique)
]
interface ITfFnPlayBack : IUnknown
{
    HRESULT QueryRange(
        [in]  ITfRange *pRange,
        [out] ITfRange **ppNewRange,
        [out] BOOL     *pfPlayable);

    HRESULT Play(
        [in] ITfRange *pRange);
}

[
  object,
  uuid(2338ac6e-2b9d-44c0-a75e-ee64f256b3bd),
  pointer_default(unique)
]
interface ITfFnPropertyUIStatus : IUnknown
{
    HRESULT GetStatus(
        [in]  REFGUID refguidProp,
        [out] DWORD   *pdw);

    HRESULT SetStatus(
        [in] REFGUID refguidProp,
        [in] DWORD   dw);
}

[
  object,
  uuid(4cea93c0-0a58-11d3-8df0-00105a2799b5),
  pointer_default(unique)
]
interface ITfFnReconversion : IUnknown
{
    HRESULT QueryRange(
        [in]  ITfRange *pRange,
              ITfRange **ppNewRange,
        [out] BOOL     *pfConvertable);

    HRESULT GetReconversion(
        [in]  ITfRange         *pRange,
        [out] ITfCandidateList **ppCandList
    );

    HRESULT Reconvert(
        [in] ITfRange *pRange);
}

[
  object,
  uuid(87a2ad8f-f27b-4920-8501-67602280175d),
  pointer_default(unique)
]
interface ITfFnSearchCandidateProvider : IUnknown
{
    HRESULT GetSearchCandidates(
        [in]  BSTR             bstrQuery,
        [in]  BSTR             bstrApplicationId,
        [out] ITfCandidateList **pplist);

    HRESULT SetResult(
        [in] BSTR bstrQuery,
        [in] BSTR bstrApplicationID,
        [in] BSTR bstrResult);
}

[
  object,
  uuid(5ab1d30c-094d-4c29-8ea5-0bf59be87bf3),
  pointer_default(unique)
]
interface ITfFnShowHelp : IUnknown
{
    HRESULT Show(
        [in] HWND hwndParent);
}

[
  object,
  uuid(5ab1d30c-094d-4c29-8ea5-0bf59be87bf3),
  pointer_default(unique)
]
interface ITfIntegratableCandidateListUIElement : IUnknown
{
    HRESULT SetIntegrationStyle(
        [in] GUID guidIntegrationStyle);

    HRESULT GetSelectionStyle(
        [out] TfIntegratableCandidateListSelectionStyle *ptfSelectionStyle);

    HRESULT OnKeyDown(
        [in]  WPARAM wParam,
        [in]  LPARAM lParam,
        [out] BOOL   *pfEaten);

    HRESULT ShowCandidateNumbers(
        [out] BOOL *pfShow);

    HRESULT FinalizeExactCompositionString(void);
}

[
  object,
  uuid(d4236675-a5bf-4570-9d42-5d6d7b02d59b),
  pointer_default(unique)
]
interface ITfLMLattice : IUnknown
{
    HRESULT QueryType(
        [in]  REFGUID rguidType,
        [out] BOOL    *pfSupported);

    HRESULT EnumLatticeElements(
        [in]  DWORD                  dwFrameStart,
        [in]  REFGUID                rguidType,
        [out] IEnumTfLatticeElements **ppEnum);
}

[
  object,
  uuid(cd91d690-a7e8-4265-9b38-8bb3bbaba7de),
  pointer_default(unique)
]
interface IUIManagerEventSink : IUnknown
{
    HRESULT OnWindowOpening(
        [in] RECT *prcBounds);

    HRESULT OnWindowOpened(
        [in] RECT *prcBounds);

    HRESULT OnWindowUpdating(
        [in] RECT *prcUpdatedBounds);

    HRESULT OnWindowUpdated(
        [in] RECT *prcUpdatedBounds);

    HRESULT OnWindowClosing(void);

    HRESULT OnWindowClosed(void);
}
