/*
 * Copyright 2005 Jacek Caban
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

import "ocidl.idl";
import "objidl.idl";
import "oleidl.idl";
import "oaidl.idl";
import "docobj.idl";

cpp_quote("#define CONTEXT_MENU_DEFAULT     0")
cpp_quote("#define CONTEXT_MENU_IMAGE       1")
cpp_quote("#define CONTEXT_MENU_CONTROL     2")
cpp_quote("#define CONTEXT_MENU_TABLE       3")
cpp_quote("#define CONTEXT_MENU_TEXTSELECT  4")
cpp_quote("#define CONTEXT_MENU_ANCHOR      5")
cpp_quote("#define CONTEXT_MENU_UNKNOWN     6")
cpp_quote("#define CONTEXT_MENU_IMGDYNSRC   7")
cpp_quote("#define CONTEXT_MENU_IMGART      8")
cpp_quote("#define CONTEXT_MENU_DEBUG       9")
cpp_quote("#define CONTEXT_MENU_VSCROLL    10")
cpp_quote("#define CONTEXT_MENU_HSCROLL    11")

cpp_quote("#define MENUEXT_SHOWDIALOG 1")

cpp_quote("#define DOCHOSTUIFLAG_BROWSER (DOCHOSTUIFLAG_DISABLE_HELP_MENU|DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE)")

cpp_quote("#define HTMLDLG_NOUI            0x0010")
cpp_quote("#define HTMLDLG_MODAL           0x0020")
cpp_quote("#define HTMLDLG_MODELESS        0x0040")
cpp_quote("#define HTMLDLG_PRINT_TEMPLATE  0x0080")
cpp_quote("#define HTMLDLG_VERIFY          0x0100")

cpp_quote("#define PRINT_DONTBOTHERUSER     0x0001")
cpp_quote("#define PRINT_WAITFORCOMPLETION  0x0002")

cpp_quote("DEFINE_GUID(CGID_MSHTML, 0xde4ba900,0x59ca,0x11cf,0x95,0x92,0x44,0x45,0x53,0x54,0x00,0x00);")
cpp_quote("#define CMDSETID_Forms3 CGID_MSHTML")

cpp_quote("#if defined(__GNUC__)")
cpp_quote("#define SZ_HTML_CLIENTSITE_OBJECTPARAM (const WCHAR[]) {'{','d','4','d','b','6','8','5','0','-','5','3','8','5','-','1','1','d','0','-','8','9','e','9','-','0','0','a','0','c','9','0','a','9','0','a','c','}',0}")
cpp_quote("#elif defined(_MSC_VER)")
cpp_quote("#define SZ_HTML_CLIENTSITE_OBJECTPARAM L\"{d4db6850-5385-11d0-89e9-00a0c90a90ac}\"")
cpp_quote("#else")
cpp_quote("static const WCHAR SZ_HTML_CLIENTSITE_OBJECTPARAM[] = {'{','d','4','d','b','6','8','5','0','-','5','3','8','5','-','1','1','d','0','-','8','9','e','9','-','0','0','a','0','c','9','0','a','9','0','a','c','}',0};")
cpp_quote("#endif")

cpp_quote("#ifndef __IHTMLWindow2_FWD_DEFINED__")
cpp_quote("#define __IHTMLWindow2_FWD_DEFINED__")
cpp_quote("typedef interface IHTMLWindow2 IHTMLWindow2;")
cpp_quote("#endif")

/*****************************************************************************
 *    IHostDialogHelper interface
 */
[
    object,
    uuid(53DEC138-A51E-11d2-861E-00C04FA35C89),
    pointer_default(unique),
    local
]
interface IHostDialogHelper : IUnknown
{
    HRESULT ShowHTMLDialog(
        HWND hwndParent,
        IMoniker *pMk,
        VARIANT *pvarArgIn,
        WCHAR *pchOptions,
        VARIANT *pvarArgOut,
        IUnknown *punkHost);
}

/*****************************************************************************
 *    HostDialogHelper coclass
 */
[
    uuid(429AF92C-A51F-11d2-861E-00C04FA35C89)
]
coclass HostDialogHelper
{
    [default] interface IHostDialogHelper;
}

/*****************************************************************************
 *    IDocHostUIHandler interface
 */

typedef enum tagDOCHOSTUITYPE {
    DOCHOSTUITYPE_BROWSE = 0,
    DOCHOSTUITYPE_AUTHOR = 1
} DOCHOSTUITYPE;

typedef enum tagDOCHOSTUIDBLCLK
{
    DOCHOSTUIDBLCLK_DEFAULT         = 0,
    DOCHOSTUIDBLCLK_SHOWPROPERTIES  = 1,
    DOCHOSTUIDBLCLK_SHOWCODE        = 2
} DOCHOSTUIDBLCLK;

typedef enum tagDOCHOSTUIFLAG
{
    DOCHOSTUIFLAG_DIALOG                      = 0x00000001,
    DOCHOSTUIFLAG_DISABLE_HELP_MENU           = 0x00000002,
    DOCHOSTUIFLAG_NO3DBORDER                  = 0x00000004,
    DOCHOSTUIFLAG_SCROLL_NO                   = 0x00000008,
    DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE     = 0x00000010,
    DOCHOSTUIFLAG_OPENNEWWIN                  = 0x00000020,
    DOCHOSTUIFLAG_DISABLE_OFFSCREEN           = 0x00000040,
    DOCHOSTUIFLAG_FLAT_SCROLLBAR              = 0x00000080,
    DOCHOSTUIFLAG_DIV_BLOCKDEFAULT            = 0x00000100,
    DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY     = 0x00000200,
    DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY     = 0x00000400,
    DOCHOSTUIFLAG_CODEPAGELINKEDFONTS         = 0x00000800,
    DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8   = 0x00001000,
    DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8    = 0x00002000,
    DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE   = 0x00004000,
    DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION   = 0x00010000,
    DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION     = 0x00020000,
    DOCHOSTUIFLAG_THEME                       = 0x00040000,
    DOCHOSTUIFLAG_NOTHEME                     = 0x00080000,
    DOCHOSTUIFLAG_NOPICS                      = 0x00100000,
    DOCHOSTUIFLAG_NO3DOUTERBORDER             = 0x00200000,
    DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP       = 0x00400000,
    DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK  = 0x00800000,
    DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL   = 0x01000000
} DOCHOSTUIFLAG;

[
    object,
    uuid(BD3F23C0-D43E-11CF-893B-00AA00BDCE1A),
    pointer_default(unique),
    local
]
interface IDocHostUIHandler : IUnknown
{
    typedef struct _DOCHOSTUIINFO
    {
        ULONG cbSize;
        DWORD dwFlags;
        DWORD dwDoubleClick;
        OLECHAR *pchHostCss;
        OLECHAR *pchHostNS;
    } DOCHOSTUIINFO;

    HRESULT ShowContextMenu(
        [in] DWORD dwID, 
        [in] POINT *ppt, 
        [in] IUnknown *pcmdtReserved,  
        [in] IDispatch *pdispReserved);

    HRESULT GetHostInfo([in, out] DOCHOSTUIINFO *pInfo);

    HRESULT ShowUI(
        [in] DWORD dwID,
        [in] IOleInPlaceActiveObject *pActiveObject,
        [in] IOleCommandTarget *pCommandTarget,
        [in] IOleInPlaceFrame *pFrame,
        [in] IOleInPlaceUIWindow *pDoc);

    HRESULT HideUI();

    HRESULT UpdateUI();

    HRESULT EnableModeless([in] BOOL fEnable);

    HRESULT OnDocWindowActivate([in] BOOL fActivate);

    HRESULT OnFrameWindowActivate([in] BOOL fActivate);

    HRESULT ResizeBorder(
        [in] LPCRECT prcBorder,
        [in] IOleInPlaceUIWindow *pUIWindow,
        [in] BOOL fRameWindow);

    HRESULT TranslateAccelerator(
        [in] LPMSG lpMsg,
        [in] const GUID *pguidCmdGroup, 
        [in] DWORD nCmdID);

    HRESULT GetOptionKeyPath(
        [out] LPOLESTR *pchKey,
        [in] DWORD dw);

    HRESULT GetDropTarget(
        [in] IDropTarget *pDropTarget, 
        [out] IDropTarget **ppDropTarget);

    HRESULT GetExternal([out] IDispatch **ppDispatch);

    HRESULT TranslateUrl(
        [in] DWORD dwTranslate,
        [in] OLECHAR *pchURLIn,
        [out] OLECHAR **ppchURLOut);

    HRESULT FilterDataObject(
        [in] IDataObject *pDO,
        [out] IDataObject **ppDORet);
}

cpp_quote("DEFINE_GUID(CGID_DocHostCommandHandler,0xf38bc242,0xb950,0x11d1,0x89,0x18,0x00,0xc0,0x4f,0xc2,0xc8,0x36);")

[
    object,
    uuid(3050F6D0-98b5-11CF-BB82-00AA00BDCE0B),
    pointer_default(unique),
    local
]
interface IDocHostUIHandler2 : IDocHostUIHandler
{
    HRESULT GetOverrideKeyPath(
        [out] LPOLESTR *pchKey,
        [in] DWORD dw);
}

/*****************************************************************************
 *    ICustomDoc interface
 */
[
    object,
    uuid(3050f3f0-98b5-11cf-bb82-00aa00bdce0b),
    pointer_default(unique),
    local
]
interface ICustomDoc : IUnknown
{
    HRESULT SetUIHandler([in] IDocHostUIHandler *pUIHandler);
}

/*****************************************************************************
 *    IDocHostShowUI interface
 */
[
    object,
    uuid(c4d244b0-d43e-11cf-893b-00aa00bdce1a),
    pointer_default(unique),
    local
]
interface IDocHostShowUI : IUnknown
{
    HRESULT ShowMessage(
        [in] HWND hwnd,
        [in] LPOLESTR lpstrText,
        [in] LPOLESTR lpstrCaption,
        [in] DWORD dwType,
        [in] LPOLESTR lpstrHelpFile,
        [in] DWORD dwHelpContext,
        [out] LRESULT *plResult);

    HRESULT ShowHelp(
        [in] HWND hwnd,
        [in] LPOLESTR pszHelpFile,
        [in] UINT uCommand,
        [in] DWORD dwData,
        [in] POINT ptMouse,
        [out] IDispatch *pDispatchObjectHit);
}

/*****************************************************************************
 *    IClassFactoryEx interface
 */

cpp_quote("#define IClassFactory3 IClassFactoryEx")
cpp_quote("#define IID_IClassFactory3 IID_IClassFactoryEx")

[
    object,
    uuid(342D1EA0-AE25-11D1-89C5-006008C3FBFC),
    pointer_default(unique),
    local
]
interface IClassFactoryEx : IClassFactory
{
    HRESULT CreateInstanceWithContext(
        IUnknown *punkContext,
        IUnknown *punkOuter,
        REFIID riid,
        [out] void **ppv);
}

cpp_quote("typedef HRESULT WINAPI SHOWHTMLDIALOGFN(HWND,IMoniker*,VARIANT*,WCHAR*,VARIANT*);")
cpp_quote("typedef HRESULT WINAPI SHOWHTMLDIALOGEXFN(HWND,IMoniker*,DWORD,VARIANT*,WCHAR*,VARIANT*);")
cpp_quote("typedef HRESULT WINAPI SHOWMODELESSHTMLDIALOGFN(HWND,IMoniker*,VARIANT*,VARIANT*,IHTMLWindow2**);")

cpp_quote("EXTERN_C HRESULT WINAPI ShowHTMLDialog(HWND,IMoniker*,VARIANT*,WCHAR*,VARIANT*);")
cpp_quote("EXTERN_C HRESULT WINAPI ShowHTMLDialogEx(HWND,IMoniker*,DWORD,VARIANT*,WCHAR*,VARIANT*);")
cpp_quote("EXTERN_C HRESULT WINAPI ShowModelessHTMLDialog(HWND,IMoniker*,VARIANT*,VARIANT*,IHTMLWindow2**);")
cpp_quote("EXTERN_C HRESULT WINAPI RunHTMLApplication(HINSTANCE,HINSTANCE,LPSTR,int);")
cpp_quote("EXTERN_C HRESULT WINAPI CreateHTMLPropertyPage(IMoniker*,IPropertyPage**);")