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

#include "sipAPI_core.h"
        #include <wx/dcsvg.h>
        #include <wx/bitmap.h>
        #include <wx/stream.h>


class sipwxSVGBitmapFileHandler : public ::wxSVGBitmapFileHandler
{
public:
    sipwxSVGBitmapFileHandler(const ::wxFileName&);
    sipwxSVGBitmapFileHandler(const ::wxSVGBitmapFileHandler&);
    virtual ~sipwxSVGBitmapFileHandler();

    /*
     * There is a protected method for every virtual method visible from
     * this class.
     */
protected:
    bool ProcessBitmap(const ::wxBitmap&, ::wxCoord, ::wxCoord, ::wxOutputStream&) const SIP_OVERRIDE;

public:
    sipSimpleWrapper *sipPySelf;

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

    char sipPyMethods[1];
};

sipwxSVGBitmapFileHandler::sipwxSVGBitmapFileHandler(const ::wxFileName& path): ::wxSVGBitmapFileHandler(path), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

sipwxSVGBitmapFileHandler::sipwxSVGBitmapFileHandler(const ::wxSVGBitmapFileHandler& a0): ::wxSVGBitmapFileHandler(a0), sipPySelf(SIP_NULLPTR)
{
    memset(sipPyMethods, 0, sizeof (sipPyMethods));
}

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

bool sipwxSVGBitmapFileHandler::ProcessBitmap(const ::wxBitmap& bitmap, ::wxCoord x, ::wxCoord y, ::wxOutputStream& stream) const
{
    sip_gilstate_t sipGILState;
    PyObject *sipMeth;

    sipMeth = sipIsPyMethod(&sipGILState, const_cast<char *>(&sipPyMethods[0]), const_cast<sipSimpleWrapper **>(&sipPySelf), SIP_NULLPTR, sipName_ProcessBitmap);

    if (!sipMeth)
        return ::wxSVGBitmapFileHandler::ProcessBitmap(bitmap, x, y, stream);

    extern bool sipVH__core_31(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper *, PyObject *, const ::wxBitmap&, ::wxCoord, ::wxCoord, ::wxOutputStream&);

    return sipVH__core_31(sipGILState, 0, sipPySelf, sipMeth, bitmap, x, y, stream);
}


PyDoc_STRVAR(doc_wxSVGBitmapFileHandler_ProcessBitmap, "ProcessBitmap(bitmap, x, y, stream) -> bool\n"
"\n"
"Writes the bitmap representation as SVG to the given stream.");

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

    {
        const ::wxBitmap* bitmap;
        ::wxCoord x;
        ::wxCoord y;
        ::wxOutputStream* stream;
        int streamState = 0;
        const ::wxSVGBitmapFileHandler *sipCpp;

        static const char *sipKwdList[] = {
            sipName_bitmap,
            sipName_x,
            sipName_y,
            sipName_stream,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, SIP_NULLPTR, "BJ9iiJ1", &sipSelf, sipType_wxSVGBitmapFileHandler, &sipCpp, sipType_wxBitmap, &bitmap, &x, &y, sipType_wxOutputStream, &stream, &streamState))
        {
            bool sipRes;

            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipRes = (sipSelfWasArg ? sipCpp->::wxSVGBitmapFileHandler::ProcessBitmap(*bitmap, x, y, *stream) : sipCpp->ProcessBitmap(*bitmap, x, y, *stream));
            Py_END_ALLOW_THREADS
            sipReleaseType(stream, sipType_wxOutputStream, streamState);

            if (PyErr_Occurred())
                return 0;

            return PyBool_FromLong(sipRes);
        }
    }

    sipNoMethod(sipParseErr, sipName_SVGBitmapFileHandler, sipName_ProcessBitmap, SIP_NULLPTR);

    return SIP_NULLPTR;
}


/* Cast a pointer to a type somewhere in its inheritance hierarchy. */
extern "C" {static void *cast_wxSVGBitmapFileHandler(void *, const sipTypeDef *);}
static void *cast_wxSVGBitmapFileHandler(void *sipCppV, const sipTypeDef *targetType)
{
    ::wxSVGBitmapFileHandler *sipCpp = reinterpret_cast<::wxSVGBitmapFileHandler *>(sipCppV);

    if (targetType == sipType_wxSVGBitmapFileHandler)
        return sipCppV;

    if (targetType == sipType_wxSVGBitmapHandler)
        return static_cast<::wxSVGBitmapHandler *>(sipCpp);

    return SIP_NULLPTR;
}


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

    if (sipState & SIP_DERIVED_CLASS)
        delete reinterpret_cast<sipwxSVGBitmapFileHandler *>(sipCppV);
    else
        delete reinterpret_cast<::wxSVGBitmapFileHandler *>(sipCppV);

    Py_END_ALLOW_THREADS
}


extern "C" {static void assign_wxSVGBitmapFileHandler(void *, Py_ssize_t, void *);}
static void assign_wxSVGBitmapFileHandler(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<::wxSVGBitmapFileHandler *>(sipDst)[sipDstIdx] = *reinterpret_cast<::wxSVGBitmapFileHandler *>(sipSrc);
}


extern "C" {static void *copy_wxSVGBitmapFileHandler(const void *, Py_ssize_t);}
static void *copy_wxSVGBitmapFileHandler(const void *sipSrc, Py_ssize_t sipSrcIdx)
{
    return new ::wxSVGBitmapFileHandler(reinterpret_cast<const ::wxSVGBitmapFileHandler *>(sipSrc)[sipSrcIdx]);
}


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

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


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

    {
        const ::wxFileName* path;
        int pathState = 0;

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

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, sipKwdList, sipUnused, "J1", sipType_wxFileName, &path, &pathState))
        {
            PyErr_Clear();

            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxSVGBitmapFileHandler(*path);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<::wxFileName *>(path), sipType_wxFileName, pathState);

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

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    {
        const ::wxSVGBitmapFileHandler* a0;

        if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, SIP_NULLPTR, sipUnused, "J9", sipType_wxSVGBitmapFileHandler, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp = new sipwxSVGBitmapFileHandler(*a0);
            Py_END_ALLOW_THREADS

            sipCpp->sipPySelf = sipSelf;

            return sipCpp;
        }
    }

    return SIP_NULLPTR;
}


/* Define this type's super-types. */
static sipEncodedTypeDef supers_wxSVGBitmapFileHandler[] = {{488, 255, 1}};


static PyMethodDef methods_wxSVGBitmapFileHandler[] = {
    {sipName_ProcessBitmap, SIP_MLMETH_CAST(meth_wxSVGBitmapFileHandler_ProcessBitmap), METH_VARARGS|METH_KEYWORDS, doc_wxSVGBitmapFileHandler_ProcessBitmap}
};

PyDoc_STRVAR(doc_wxSVGBitmapFileHandler, "SVGBitmapFileHandler(path)\n"
"\n"
"Handler saving bitmaps to external PNG files and linking to it from\n"
"the SVG.");


sipClassTypeDef sipTypeDef__core_wxSVGBitmapFileHandler = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_CLASS,
        sipNameNr_wxSVGBitmapFileHandler,
        SIP_NULLPTR,
        SIP_NULLPTR,
    },
    {
        sipNameNr_SVGBitmapFileHandler,
        {0, 0, 1},
        1, methods_wxSVGBitmapFileHandler,
        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_wxSVGBitmapFileHandler,
    -1,
    -1,
    supers_wxSVGBitmapFileHandler,
    SIP_NULLPTR,
    init_type_wxSVGBitmapFileHandler,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    dealloc_wxSVGBitmapFileHandler,
    assign_wxSVGBitmapFileHandler,
    SIP_NULLPTR,
    copy_wxSVGBitmapFileHandler,
    release_wxSVGBitmapFileHandler,
    cast_wxSVGBitmapFileHandler,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
};
