/*
 * 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/eventfilter.h>
        #include <wx/event.h>


class sipwxEventFilter : public ::wxEventFilter
{
public:
    sipwxEventFilter();
    virtual ~sipwxEventFilter();

    /*
     * There is a protected method for every virtual method visible from
     * this class.
     */
protected:
    int FilterEvent(::wxEvent&) SIP_OVERRIDE;

public:
    sipSimpleWrapper *sipPySelf;

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

    char sipPyMethods[1];
};

sipwxEventFilter::sipwxEventFilter(): ::wxEventFilter(), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

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

int sipwxEventFilter::FilterEvent(::wxEvent& event)
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

    sipMeth = sipIsPyMethod(&sipGILState, &sipPyMethods[0], &sipPySelf, sipName_EventFilter, sipName_FilterEvent);

    if (!sipMeth)
        return 0;

    extern int sipVH__core_111(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *, ::wxEvent&);

    return sipVH__core_111(sipGILState, 0, sipPySelf, sipMeth, event);
}


PyDoc_STRVAR(doc_wxEventFilter_FilterEvent, "FilterEvent(event) -> int\n"
"\n"
"Override this method to implement event pre-processing.");

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

    {
        ::wxEvent* event;
        ::wxEventFilter *sipCpp;

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

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ9", &sipSelf, sipType_wxEventFilter, &sipCpp, sipType_wxEvent, &event))
        {
            int sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_EventFilter, sipName_FilterEvent);
                return SIP_NULLPTR;
            }

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->FilterEvent(*event);
            Py_END_ALLOW_THREADS

            if (PyErr_Occurred())
                return 0;

            return PyLong_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_EventFilter, sipName_FilterEvent, SIP_NULLPTR);

    return SIP_NULLPTR;
}


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

    if (sipState & SIP_DERIVED_CLASS)
        delete reinterpret_cast<sipwxEventFilter *>(sipCppV);
    else
        delete reinterpret_cast< ::wxEventFilter *>(sipCppV);

    Py_END_ALLOW_THREADS
}


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

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


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

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

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxEventFilter();
            Py_END_ALLOW_THREADS

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

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


static PyMethodDef methods_wxEventFilter[] = {
    {sipName_FilterEvent, SIP_MLMETH_CAST(meth_wxEventFilter_FilterEvent), METH_VARARGS|METH_KEYWORDS, doc_wxEventFilter_FilterEvent}
};

static sipEnumMemberDef enummembers_wxEventFilter[] = {
    {sipName_Event_Ignore, static_cast<int>(::wxEventFilter::Event_Ignore), -1},
    {sipName_Event_Processed, static_cast<int>(::wxEventFilter::Event_Processed), -1},
    {sipName_Event_Skip, static_cast<int>(::wxEventFilter::Event_Skip), -1},
};

PyDoc_STRVAR(doc_wxEventFilter, "EventFilter() -> None\n"
"\n"
"A global event filter for pre-processing all the events generated in\n"
"the program.");


sipClassTypeDef sipTypeDef__core_wxEventFilter = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_ABSTRACT|SIP_TYPE_CLASS,
        sipNameNr_wxEventFilter,
        SIP_NULLPTR,
        SIP_NULLPTR,
    },
    {
        sipNameNr_EventFilter,
        {0, 0, 1},
        1, methods_wxEventFilter,
        3, enummembers_wxEventFilter,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
    },
    doc_wxEventFilter,
    -1,
    -1,
    SIP_NULLPTR,
    SIP_NULLPTR,
    init_type_wxEventFilter,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    dealloc_wxEventFilter,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    release_wxEventFilter,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    sizeof (::wxEventFilter),
};
