/*
 * Copyright 2017 Alex Henrie
 *
 * 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 "oaidl.idl";
import "ocidl.idl";
import "docobj.idl";
import "mshtml.idl";

#include "dhtmldid.h"

#ifndef __WIDL__
#define threading(model)
#define progid(str)
#define vi_progid(str)
#endif

[
    uuid(683364a1-b37d-11d1-adc5-006008a5848c),
    version(1.0)
]
library DHTMLEDLib
{
    importlib("stdole2.tlb");

    typedef
    [
        uuid(7179FC44-B2E4-11d1-ADC5-006008A5848C)
    ]
    enum DHTMLEDITAPPEARANCE {
        DEAPPEARANCE_FLAT,
        DEAPPEARANCE_3D
    } DHTMLEDITAPPEARANCE;

    typedef
    [
        uuid(bf82426a-b961-11d1-adc5-006008a5848c)
    ]
    enum DHTMLEDITCMDF {
        DECMDF_NOTSUPPORTED = 0,
        DECMDF_DISABLED = 1,
        DECMDF_ENABLED = 3,
        DECMDF_LATCHED = 7,
        DECMDF_NINCHED = 11
    } DHTMLEDITCMDF;

    typedef enum DHTMLEDITCMDID {
        DECMD_BOLD = 5000,
        DECMD_COPY = 5002,
        DECMD_CUT,
        DECMD_DELETE,
        DECMD_DELETECELLS,
        DECMD_DELETECOLS,
        DECMD_DELETEROWS,
        DECMD_FINDTEXT,
        DECMD_FONT,
        DECMD_GETBACKCOLOR,
        DECMD_GETBLOCKFMT,
        DECMD_GETBLOCKFMTNAMES,
        DECMD_GETFONTNAME,
        DECMD_GETFONTSIZE,
        DECMD_GETFORECOLOR,
        DECMD_HYPERLINK,
        DECMD_IMAGE,
        DECMD_INDENT,
        DECMD_INSERTCELL,
        DECMD_INSERTCOL,
        DECMD_INSERTROW,
        DECMD_INSERTTABLE,
        DECMD_ITALIC,
        DECMD_JUSTIFYCENTER,
        DECMD_JUSTIFYLEFT,
        DECMD_JUSTIFYRIGHT,
        DECMD_LOCK_ELEMENT,
        DECMD_MAKE_ABSOLUTE,
        DECMD_MERGECELLS,
        DECMD_ORDERLIST,
        DECMD_OUTDENT,
        DECMD_PASTE,
        DECMD_REDO,
        DECMD_REMOVEFORMAT,
        DECMD_SELECTALL,
        DECMD_SEND_BACKWARD,
        DECMD_BRING_FORWARD,
        DECMD_SEND_BELOW_TEXT,
        DECMD_BRING_ABOVE_TEXT,
        DECMD_SEND_TO_BACK,
        DECMD_BRING_TO_FRONT,
        DECMD_SETBACKCOLOR,
        DECMD_SETBLOCKFMT,
        DECMD_SETFONTNAME,
        DECMD_SETFONTSIZE,
        DECMD_SETFORECOLOR,
        DECMD_SPLITCELL,
        DECMD_UNDERLINE,
        DECMD_UNDO,
        DECMD_UNLINK,
        DECMD_UNORDERLIST,
        DECMD_PROPERTIES
    } DHTMLEDITCMDID;

    [
        object,
        uuid(ce04b590-2b1f-11d2-8d1e-00a0c959bc0a),
        dual,
        pointer_default(unique)
    ]
    interface IDHTMLSafe : IDispatch
    {
        [
            id(DISPID_EXECCOMMAND)
        ]
        HRESULT ExecCommand(
            [in] DHTMLEDITCMDID cmd_id,
            [in, defaultvalue(OLECMDEXECOPT_DODEFAULT)] OLECMDEXECOPT options,
            [in, optional] VARIANT *code_in,
            [out, retval] VARIANT *code_out
        );

        [
            id(DISPID_QUERYSTATUS)
        ]
        HRESULT QueryStatus(
            [in] DHTMLEDITCMDID cmd_id,
            [out, retval] DHTMLEDITCMDF *status
        );

        [
            id(DISPID_SETCONTEXTMENU)
        ]
        HRESULT SetContextMenu(
            [in] VARIANT *strings,
            [in] VARIANT *states
        );

        [
            id(DISPID_NEWDOCUMENT)
        ]
        HRESULT NewDocument();

        [
            id(DISPID_LOADURL)
        ]
        HRESULT LoadURL(
            [in] BSTR url
        );

        [
            id(DISPID_FILTERSRCCODE)
        ]
        HRESULT FilterSourceCode(
            [in] BSTR in,
            [out, retval] BSTR *out
        );

        [
            id(DISPID_REFRESHDOC)
        ]
        HRESULT Refresh();

        [
            propget,
            id(DISPID_DOCUMENT)
        ]
        HRESULT DOM(
            [out, retval] IHTMLDocument2 **value
        );

        [
            propget,
            id(DISPID_DOCUMENTHTML)
        ]
        HRESULT DocumentHTML(
            [out, retval] BSTR *value
        );

        [
            propput,
            id(DISPID_DOCUMENTHTML)
        ]
        HRESULT DocumentHTML(
            [in] BSTR html
        );

        [
            propget,
            id(DISPID_ACTIVATEAPPLETS)
        ]
        HRESULT ActivateApplets(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_ACTIVATEAPPLETS)
        ]
        HRESULT ActivateApplets(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_ACTIVATEACTIVEXCONTROLS)
        ]
        HRESULT ActivateActiveXControls(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_ACTIVATEACTIVEXCONTROLS)
        ]
        HRESULT ActivateActiveXControls(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_ACTIVATEDTCS)
        ]
        HRESULT ActivateDTCs(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_ACTIVATEDTCS)
        ]
        HRESULT ActivateDTCs(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_SHOWDETAILS)
        ]
        HRESULT ShowDetails(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_SHOWDETAILS)
        ]
        HRESULT ShowDetails(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_SHOWBORDERS)
        ]
        HRESULT ShowBorders(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_SHOWBORDERS)
        ]
        HRESULT ShowBorders(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_DHTMLEDITAPPEARANCE)
        ]
        HRESULT Appearance(
            [out, retval] DHTMLEDITAPPEARANCE *value
        );

        [
            propput,
            id(DISPID_DHTMLEDITAPPEARANCE)
        ]
        HRESULT Appearance(
            [in] DHTMLEDITAPPEARANCE value
        );

        [
            propget,
            id(DISPID_DHTMLEDITSCROLLBARS)
        ]
        HRESULT Scrollbars(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_DHTMLEDITSCROLLBARS)
        ]
        HRESULT Scrollbars(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_SCROLLBARAPPEARANCE)
        ]
        HRESULT ScrollbarAppearance(
            [out, retval] DHTMLEDITAPPEARANCE *value
        );

        [
            propput,
            id(DISPID_SCROLLBARAPPEARANCE)
        ]
        HRESULT ScrollbarAppearance(
            [in] DHTMLEDITAPPEARANCE value
        );

        [
            propget,
            id(DISPID_SOURCECODEPRESERVATION)
        ]
        HRESULT SourceCodePreservation(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_SOURCECODEPRESERVATION)
        ]
        HRESULT SourceCodePreservation(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_ABSOLUTEDROPMODE)
        ]
        HRESULT AbsoluteDropMode(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_ABSOLUTEDROPMODE)
        ]
        HRESULT AbsoluteDropMode(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_SNAPTOGRIDX)
        ]
        HRESULT SnapToGridX(
            [out, retval] long *value
        );

        [
            propput,
            id(DISPID_SNAPTOGRIDX)
        ]
        HRESULT SnapToGridX(
            [in] long value
        );

        [
            propget,
            id(DISPID_SNAPTOGRIDY)
        ]
        HRESULT SnapToGridY(
            [out, retval] long *value
        );

        [
            propput,
            id(DISPID_SNAPTOGRIDY)
        ]
        HRESULT SnapToGridY(
            [in] long value
        );

        [
            propget,
            id(DISPID_SNAPTOGRID)
        ]
        HRESULT SnapToGrid(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_SNAPTOGRID)
        ]
        HRESULT SnapToGrid(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_ISDIRTY)
        ]
        HRESULT IsDirty(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propget,
            id(DISPID_CURRENTDOCUMENTPATH)
        ]
        HRESULT CurrentDocumentPath(
            [out, retval] BSTR *value
        );

        [
            propget,
            id(DISPID_BASEURL)
        ]
        HRESULT BaseURL(
            [out, retval] BSTR *value
        );

        [
            propput,
            id(DISPID_BASEURL)
        ]
        HRESULT BaseURL(
            [in] BSTR value
        );

        [
            propget,
            id(DISPID_DOCUMENTTITLE)
        ]
        HRESULT DocumentTitle(
            [out, retval] BSTR *value
        );

        [
            propget,
            id(DISPID_USEDIVONCR)
        ]
        HRESULT UseDivOnCarriageReturn(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_USEDIVONCR)
        ]
        HRESULT UseDivOnCarriageReturn(
            [in] VARIANT_BOOL value
        );

        [
            propget,
            id(DISPID_BUSY)
        ]
        HRESULT Busy(
            [out, retval] VARIANT_BOOL *value
        );
    };

    [
        uuid(d1fc78e8-b380-11d1-adc5-006008a5848c)
    ]
    dispinterface _DHTMLSafeEvents
    {
    properties:
    methods:
        [
            id(DISPID_DOCUMENTCOMPLETE)
        ]
        void DocumentComplete();

        [
            id(DISPID_DISPLAYCHANGED)
        ]
        void DisplayChanged();

        [
            id(DISPID_SHOWCONTEXTMENU)
        ]
        void ShowContextMenu(
            [in] long x,
            [in] long y
        );

        [
            id(DISPID_CONTEXTMENUACTION)
        ]
        void ContextMenuAction(
            [in] long index
        );

        [
            id(DISPID_ONMOUSEDOWN)
        ]
        void onmousedown();

        [
            id(DISPID_ONMOUSEMOVE)
        ]
        void onmousemove();

        [
            id(DISPID_ONMOUSEUP)
        ]
        void onmouseup();

        [
            id(DISPID_ONMOUSEOUT)
        ]
        void onmouseout();

        [
            id(DISPID_ONMOUSEOVER)
        ]
        void onmouseover();

        [
            id(DISPID_ONCLICK)
        ]
        void onclick();

        [
            id(DISPID_ONDBLCLICK)
        ]
        void ondblclick();

        [
            id(DISPID_ONKEYDOWN)
        ]
        void onkeydown();

        [
            id(DISPID_ONKEYPRESS)
        ]
        void onkeypress();

        [
            id(DISPID_ONKEYUP)
        ]
        void onkeyup();

        [
            id(DISPID_ONBLUR)
        ]
        void onblur();

        [
            id(DISPID_ONREADYSTATECHANGE)
        ]
        void onreadystatechange();
    };

    [
        uuid(2d360201-fff5-11d1-8d03-00a0c959bc0a),
        threading(apartment),
        progid("DHTMLSafe.DHTMLSafe.1"),
        vi_progid("DHTMLSafe.DHTMLSafe")
    ]
    coclass DHTMLSafe
    {
        [default] interface IDHTMLSafe;
        [default, source] interface _DHTMLSafeEvents;
    };

    [
        uuid(ce04b591-2b1f-11d2-8d1e-00a0c959bc0a),
        dual,
        pointer_default(unique)
    ]
    interface IDHTMLEdit : IDHTMLSafe
    {
        [
            id(DISPID_LOADDOCUMENT)
        ]
        HRESULT LoadDocument(
            [in] VARIANT *path,
            [in, optional] VARIANT *prompt
        );

        [
            id(DISPID_SAVEDOCUMENT)
        ]
        HRESULT SaveDocument(
            [in] VARIANT *path,
            [in, optional] VARIANT *prompt
        );

        [
            id(DISPID_PRINT)
        ]
        HRESULT PrintDocument(
            [in, optional] VARIANT *prompt
        );

        [
            propget,
            id(DISPID_BROWSEMODE)
        ]
        HRESULT BrowseMode(
            [out, retval] VARIANT_BOOL *value
        );

        [
            propput,
            id(DISPID_BROWSEMODE)
        ]
        HRESULT BrowseMode(
            [in] VARIANT_BOOL value
        );
    };

    [
        uuid(588d5040-cf28-11d1-8cd3-00a0c959bc0a)
    ]
    dispinterface _DHTMLEditEvents
    {
    properties:
    methods:
        [
            id(DISPID_DOCUMENTCOMPLETE)
        ]
        void DocumentComplete();

        [
            id(DISPID_DISPLAYCHANGED)
        ]
        void DisplayChanged();

        [
            id(DISPID_SHOWCONTEXTMENU)
        ]
        void ShowContextMenu(
            [in] long x,
            [in] long y
        );

        [
            id(DISPID_CONTEXTMENUACTION)
        ]
        void ContextMenuAction(
            [in] long index
        );

        [
            id(DISPID_ONMOUSEDOWN)
        ]
        void onmousedown();

        [
            id(DISPID_ONMOUSEMOVE)
        ]
        void onmousemove();

        [
            id(DISPID_ONMOUSEUP)
        ]
        void onmouseup();

        [
            id(DISPID_ONMOUSEOUT)
        ]
        void onmouseout();

        [
            id(DISPID_ONMOUSEOVER)
        ]
        void onmouseover();

        [
            id(DISPID_ONCLICK)
        ]
        void onclick();

        [
            id(DISPID_ONDBLCLICK)
        ]
        void ondblclick();

        [
            id(DISPID_ONKEYDOWN)
        ]
        void onkeydown();

        [
            id(DISPID_ONKEYPRESS)
        ]
        void onkeypress();

        [
            id(DISPID_ONKEYUP)
        ]
        void onkeyup();

        [
            id(DISPID_ONBLUR)
        ]
        void onblur();

        [
            id(DISPID_ONREADYSTATECHANGE)
        ]
        void onreadystatechange();
    };

    [
        uuid(2d360200-fff5-11d1-8d03-00a0c959bc0a),
        threading(apartment),
        progid("DHTMLEdit.DHTMLEdit.1"),
        vi_progid("DHTMLEdit.DHTMLEdit")
    ]
    coclass DHTMLEdit
    {
        [default] interface IDHTMLEdit;
        [default, source] interface _DHTMLEditEvents;
    };
}
