/*
 * Interface wrapper code.
 *
 * Generated by SIP 6.15.1
 *
 *     Copyright: (c) 2020 by Total Control Software
 *     License:   wxWindows License
 */

#include "sipAPI_core.h"
        #include <wx/modalhook.h>
        #include <wx/dialog.h>


class sipwxModalDialogHook : public ::wxModalDialogHook
{
public:
    sipwxModalDialogHook();
    virtual ~sipwxModalDialogHook();

    /*
     * There is a public method for every protected method visible from
     * this class.
     */
    int sipProtect_Enter(::wxDialog*);
    void sipProtectVirt_Exit(bool, ::wxDialog*);

    /*
     * There is a protected method for every virtual method visible from
     * this class.
     */
protected:
    void Exit(::wxDialog*) SIP_OVERRIDE;
    int Enter(::wxDialog*) SIP_OVERRIDE;

public:
    sipSimpleWrapper *sipPySelf;

private:
    sipwxModalDialogHook(const sipwxModalDialogHook &);
    sipwxModalDialogHook &operator = (const sipwxModalDialogHook &);

    char sipPyMethods[2];
};

sipwxModalDialogHook::sipwxModalDialogHook(): ::wxModalDialogHook(), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

sipwxModalDialogHook::~sipwxModalDialogHook()
{
    sipInstanceDestroyedEx(&sipPySelf);
}

void sipwxModalDialogHook::Exit(::wxDialog*dialog)
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

    sipMeth = sipIsPyMethod(&sipGILState, &sipPyMethods[0], &sipPySelf, SIP_NULLPTR, sipName_Exit);

    if (!sipMeth)
    {
        ::wxModalDialogHook::Exit(dialog);
        return;
    }

    extern void sipVH__core_248(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *, ::wxDialog*);

    sipVH__core_248(sipGILState, 0, sipPySelf, sipMeth, dialog);
}

int sipwxModalDialogHook::Enter(::wxDialog*dialog)
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

    sipMeth = sipIsPyMethod(&sipGILState, &sipPyMethods[1], &sipPySelf, sipName_ModalDialogHook, sipName_Enter);

    if (!sipMeth)
        return 0;

    extern int sipVH__core_247(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *, ::wxDialog*);

    return sipVH__core_247(sipGILState, 0, sipPySelf, sipMeth, dialog);
}

int sipwxModalDialogHook::sipProtect_Enter(::wxDialog*dialog)
{
    return Enter(dialog);
}

void sipwxModalDialogHook::sipProtectVirt_Exit(bool sipSelfWasArg, ::wxDialog*dialog)
{
    (sipSelfWasArg ? ::wxModalDialogHook::Exit(dialog) : Exit(dialog));
}


PyDoc_STRVAR(doc_wxModalDialogHook_Register, "Register() -> None\n"
"\n"
"Register this hook as being active.");

extern "C" {static PyObject *meth_wxModalDialogHook_Register(PyObject *, PyObject *);}
static PyObject *meth_wxModalDialogHook_Register(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        ::wxModalDialogHook *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxModalDialogHook, &sipCpp))
        {
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp->Register();
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    sipNoMethod(sipParseErr, sipName_ModalDialogHook, sipName_Register, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxModalDialogHook_Unregister, "Unregister() -> None\n"
"\n"
"Unregister this hook.");

extern "C" {static PyObject *meth_wxModalDialogHook_Unregister(PyObject *, PyObject *);}
static PyObject *meth_wxModalDialogHook_Unregister(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = SIP_NULLPTR;

    {
        ::wxModalDialogHook *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxModalDialogHook, &sipCpp))
        {
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp->Unregister();
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    sipNoMethod(sipParseErr, sipName_ModalDialogHook, sipName_Unregister, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxModalDialogHook_Enter, "Enter(dialog) -> int\n"
"\n"
"Called by wxWidgets before showing any modal dialogs.");

extern "C" {static PyObject *meth_wxModalDialogHook_Enter(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxModalDialogHook_Enter(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;
    PyObject *sipOrigSelf = sipSelf;

    {
        ::wxDialog* dialog;
        sipwxModalDialogHook *sipCpp;

        static const char *sipKwdList[] = {
            sipName_dialog,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ8", &sipSelf, sipType_wxModalDialogHook, &sipCpp, sipType_wxDialog, &dialog))
        {
            int sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_ModalDialogHook, sipName_Enter);
                return SIP_NULLPTR;
            }

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->sipProtect_Enter(dialog);
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            return PyLong_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_ModalDialogHook, sipName_Enter, SIP_NULLPTR);

    return SIP_NULLPTR;
}


PyDoc_STRVAR(doc_wxModalDialogHook_Exit, "Exit(dialog) -> None\n"
"\n"
"Called by wxWidgets after dismissing the modal dialog.");

extern "C" {static PyObject *meth_wxModalDialogHook_Exit(PyObject *, PyObject *, PyObject *);}
static PyObject *meth_wxModalDialogHook_Exit(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = SIP_NULLPTR;
    bool sipSelfWasArg = (!sipSelf || sipIsDerivedClass((sipSimpleWrapper *)sipSelf));

    {
        ::wxDialog* dialog;
        sipwxModalDialogHook *sipCpp;

        static const char *sipKwdList[] = {
            sipName_dialog,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ8", &sipSelf, sipType_wxModalDialogHook, &sipCpp, sipType_wxDialog, &dialog))
        {
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp->sipProtectVirt_Exit(sipSelfWasArg, dialog);
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    sipNoMethod(sipParseErr, sipName_ModalDialogHook, sipName_Exit, SIP_NULLPTR);

    return SIP_NULLPTR;
}


/* Call the instance's destructor. */
extern "C" {static void release_wxModalDialogHook(void *, int);}
static void release_wxModalDialogHook(void *sipCppV, int sipState)
{
    Py_BEGIN_ALLOW_THREADS

    if (sipState & SIP_DERIVED_CLASS)
        delete reinterpret_cast<sipwxModalDialogHook *>(sipCppV);
    else
        delete reinterpret_cast< ::wxModalDialogHook *>(sipCppV);

    Py_END_ALLOW_THREADS
}


extern "C" {static void dealloc_wxModalDialogHook(sipSimpleWrapper *);}
static void dealloc_wxModalDialogHook(sipSimpleWrapper *sipSelf)
{
    if (sipIsDerivedClass(sipSelf))
        reinterpret_cast<sipwxModalDialogHook *>(sipGetAddress(sipSelf))->sipPySelf = SIP_NULLPTR;

    if (sipIsOwnedByPython(sipSelf))
    {
        release_wxModalDialogHook(sipGetAddress(sipSelf), sipIsDerivedClass(sipSelf));
    }
}


extern "C" {static void *init_type_wxModalDialogHook(sipSimpleWrapper *, PyObject *, PyObject *, PyObject **, PyObject **, PyObject **);}
static void *init_type_wxModalDialogHook(sipSimpleWrapper *sipSelf, PyObject *sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **, PyObject **sipParseErr)
{
    sipwxModalDialogHook *sipCpp = SIP_NULLPTR;

    {
        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, ""))
        {
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxModalDialogHook();
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
            {
                delete sipCpp;
                return SIP_NULLPTR;
            }

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


static PyMethodDef methods_wxModalDialogHook[] = {
    {sipName_Enter, SIP_MLMETH_CAST(meth_wxModalDialogHook_Enter), METH_VARARGS|METH_KEYWORDS, doc_wxModalDialogHook_Enter},
    {sipName_Exit, SIP_MLMETH_CAST(meth_wxModalDialogHook_Exit), METH_VARARGS|METH_KEYWORDS, doc_wxModalDialogHook_Exit},
    {sipName_Register, meth_wxModalDialogHook_Register, METH_VARARGS, doc_wxModalDialogHook_Register},
    {sipName_Unregister, meth_wxModalDialogHook_Unregister, METH_VARARGS, doc_wxModalDialogHook_Unregister}
};

PyDoc_STRVAR(doc_wxModalDialogHook, "ModalDialogHook() -> None\n"
"\n"
"Allows intercepting all modal dialog calls.");


sipClassTypeDef sipTypeDef__core_wxModalDialogHook = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_ABSTRACT|SIP_TYPE_CLASS,
        sipNameNr_wxModalDialogHook,
        SIP_NULLPTR,
        SIP_NULLPTR,
    },
    {
        sipNameNr_ModalDialogHook,
        {0, 0, 1},
        4, methods_wxModalDialogHook,
        0, SIP_NULLPTR,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
    },
    doc_wxModalDialogHook,
    -1,
    -1,
    SIP_NULLPTR,
    SIP_NULLPTR,
    init_type_wxModalDialogHook,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    dealloc_wxModalDialogHook,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    release_wxModalDialogHook,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    sizeof (::wxModalDialogHook),
};
