/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.51 from the
 * contents of Header.xs. Do not edit this file, edit Header.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "Header.xs"
    /*
    ###########################################################################
    # (@)PACKAGE:Win32::GUI::Header
    #
    # $Id: Header.xs,v 1.6 2010/04/08 21:26:48 jwgui Exp $
    #
    ###########################################################################
    */

#include "GUI.h"

void 
Header_onPreCreate(NOTXSPROC LPPERLWIN32GUI_CREATESTRUCT perlcs) {

    perlcs->cs.lpszClass = WC_HEADER;
    perlcs->cs.style = WS_VISIBLE | WS_CHILD | HDS_HORZ;
}

BOOL
Header_onParseOption(NOTXSPROC char *option, SV* value, LPPERLWIN32GUI_CREATESTRUCT perlcs) {

    BOOL retval = TRUE;

    if(strcmp(option, "-imagelist") == 0) {
        perlcs->hImageList = (HIMAGELIST) handle_From(NOTXSCALL value);
    } else if BitmaskOptionValue("-buttons",    perlcs->cs.style, HDS_BUTTONS)
    } else if BitmaskOptionValue("-dragdrop",   perlcs->cs.style, HDS_DRAGDROP)
    } else if BitmaskOptionValue("-fulldrag",   perlcs->cs.style, HDS_FULLDRAG)
    } else if BitmaskOptionValue("-hidden",     perlcs->cs.style, HDS_HIDDEN)
    } else if BitmaskOptionValue("-horizontal", perlcs->cs.style, HDS_HORZ)
    } else if BitmaskOptionValue("-hottrack",   perlcs->cs.style, HDS_HOTTRACK)
    } else if BitmaskOptionValue("-nodivider",  perlcs->cs.style, CCS_NODIVIDER)
    } else retval = FALSE;

    return retval;
}

void 
Header_onPostCreate(NOTXSPROC HWND myhandle, LPPERLWIN32GUI_CREATESTRUCT perlcs) {

    if(perlcs->hImageList != NULL)
        Header_SetImageList (myhandle, perlcs->hImageList);
}

BOOL
Header_onParseEvent(NOTXSPROC char *name, int* eventID) {

    BOOL retval = TRUE;

         if Parse_Event("BeginTrack",      PERLWIN32GUI_NEM_CONTROL1)
    else if Parse_Event("EndTrack",        PERLWIN32GUI_NEM_CONTROL2)
    else if Parse_Event("Track",           PERLWIN32GUI_NEM_CONTROL3)
    else if Parse_Event("DividerDblClick", PERLWIN32GUI_NEM_CONTROL4)
    else if Parse_Event("ItemClick",       PERLWIN32GUI_NEM_CONTROL5)
    else if Parse_Event("ItemDblClick",    PERLWIN32GUI_NEM_CONTROL6)
    else retval = FALSE;

    return retval;
}

int
Header_onEvent (NOTXSPROC LPPERLWIN32GUI_USERDATA perlud, UINT uMsg, WPARAM wParam, LPARAM lParam) {

    int PerlResult = 1;

    if ( uMsg == WM_NOTIFY ) {

        LPNMHEADER nmh = (LPNMHEADER) lParam;

        switch (nmh->hdr.code) {

        case HDN_BEGINTRACK :

            /*
             * (@)EVENT:BeginTrack(INDEX, WIDTH)
             * Sent when a divider of the Header control
             * is being moved; the event must return 0 to
             * prevent moving the divider, 1 to allow it.
             * Passes the zero-based INDEX
             * of the item being resized and its current
             * WIDTH.
             * (@)APPLIES_TO:Header
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL1, "BeginTrack",
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->iItem,
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->pitem->cxy,
                    -1);

            // Force result if event is handle
            if (perlud->dwPlStyle & PERLWIN32GUI_EVENTHANDLING) {
                perlud->forceResult = (PerlResult == 0 ? TRUE : FALSE);
                PerlResult = 0; // MsgLoop return ForceResult 
            }
            break;

        case HDN_ENDTRACK :

            /*
             * (@)EVENT:EndTrack(INDEX, WIDTH)
             * Sent when a divider of the Header control
             * has been moved. Passes the zero-based INDEX
             * of the item being resized and its current
             * WIDTH.
             * (@)APPLIES_TO:Header
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL2, "EndTrack",
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->iItem,
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->pitem->cxy,
                    -1);
            break;

        case HDN_TRACK :

            /*
             * (@)EVENT:Track(INDEX, WIDTH)
             * Sent while a divider of the Header control
             * is being moved; the event must return 1 to
             * continue moving the divider, 0 to end its
             * movement.
             * Passes the zero-based INDEX
             * of the item being resized and its current
             * WIDTH.
             * (@)APPLIES_TO:Header
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL3, "Track",
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->iItem,
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->pitem->cxy,
                    -1);

            // Force result if event is handle
            if (perlud->dwPlStyle & PERLWIN32GUI_EVENTHANDLING) {
                perlud->forceResult = (PerlResult == 0 ? TRUE : FALSE);
                PerlResult = 0; // MsgLoop return ForceResult 
            }
            break;

        case HDN_DIVIDERDBLCLICK :

            /*
             * (@)EVENT:DividerDblClick(INDEX)
             * Sent when the user double-clicked on a
             * divider of the Header control.
             * (@)APPLIES_TO:Header
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL4, "DividerDblClick",
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->iItem,
                    -1);
            break;

        case HDN_ITEMCLICK :

            /*
             * (@)EVENT:ItemClick(INDEX)
             * Sent when the user clicked on a Header
             * item.
             * (@)APPLIES_TO:Header
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL5, "ItemClick",
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->iItem,
                    -1);
            break;

        case HDN_ITEMDBLCLICK :

            /*
             * (@)EVENT:ItemDblClick(INDEX)
             * Sent when the user double-clicked on a Header
             * item.
             * (@)APPLIES_TO:Header
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL6, "ItemDblClick",
                    PERLWIN32GUI_ARGTYPE_LONG, (LONG) nmh->iItem,
                    -1);
            break;
        }
    }

    return PerlResult;
}


#line 192 "Header.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) STATIC XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) STATIC XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

#line 336 "Header.c"
#pragma message( "*** PACKAGE Win32::GUI::Header..." )

XS_EUPXS(XS_Win32__GUI__Header_CreateDragImage); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_CreateDragImage)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, index");
    {
	HWND	handle;
	int	index = (int)SvIV(ST(1))
;
	HIMAGELIST	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 196 "Header.xs"
    RETVAL = (HIMAGELIST) Header_CreateDragImage(handle, index);
#line 363 "Header.c"
	XSprePUSH;
	PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_DeleteItem); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_DeleteItem)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, index");
    {
	HWND	handle;
	int	index = (int)SvIV(ST(1))
;
	LRESULT	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 208 "Header.xs"
    RETVAL = Header_DeleteItem(handle, index);
#line 395 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_GetImageList); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_GetImageList)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	HIMAGELIST	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 219 "Header.xs"
    RETVAL = (HIMAGELIST) Header_GetImageList(handle);
#line 425 "Header.c"
	XSprePUSH;
	PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_GetItem); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_GetItem)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, index");
    {
	HWND	handle;
	int	index = (int)SvIV(ST(1))
;
#line 231 "Header.xs"
    HDITEM Item;
#line 445 "Header.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 233 "Header.xs"
    ZeroMemory(&Item, sizeof(HDITEM));
    Item.mask = HDI_BITMAP | HDI_FORMAT | HDI_HEIGHT | HDI_IMAGE  | HDI_ORDER  | HDI_TEXT | HDI_WIDTH;
    if(Header_GetItem(handle, index, &Item)) {
        EXTEND(SP, 14);
        XST_mPV( 0, "-text");
        XST_mPV( 1, Item.pszText);
        XST_mPV( 2, "-image");
        XST_mIV( 3, Item.iImage);
        XST_mPV( 4, "-bitmap");
        XST_mIV( 5, PTR2IV(Item.hbm));
        XST_mPV( 6, "-bitmaponright");
        XST_mIV( 7, (Item.fmt & HDF_BITMAP_ON_RIGHT));
        XST_mPV( 8, "-cxy");
        XST_mIV( 9, Item.cxy);
        XST_mPV(10, "-order");
        XST_mIV(11, Item.iOrder);
        XST_mPV(12, "-align");
        if ( Item.fmt & HDF_CENTER)
            XST_mPV(13, "center");
        else if (Item.fmt & HDF_RIGHT)
            XST_mPV(13, "right");
        else
            XST_mPV(13, "left");
        XSRETURN(14);
    } else {
        XSRETURN_UNDEF;
    }
#line 484 "Header.c"
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_GetItemCount); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_GetItemCount)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	int	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 271 "Header.xs"
    RETVAL = Header_GetItemCount(handle);
#line 513 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_GetItemRect); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_GetItemRect)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 2)
       croak_xs_usage(cv,  "handle, index");
    {
	HWND	handle;
	int	index = (int)SvIV(ST(1))
;
#line 288 "Header.xs"
    RECT rect;
#line 534 "Header.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 290 "Header.xs"
    if(Header_GetItemRect(handle, index, &rect)) {
        EXTEND(SP, 4);
        XST_mIV(0, rect.left);
        XST_mIV(1, rect.top);
        XST_mIV(2, rect.right);
        XST_mIV(3, rect.bottom);
        XSRETURN(4);
    } else {
        XSRETURN_UNDEF;
    }
#line 556 "Header.c"
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_GetOrderArray); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_GetOrderArray)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
#line 308 "Header.xs"
    int iItems, *lpiArray;
#line 572 "Header.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 310 "Header.xs"
    iItems = Header_GetItemCount(handle);
    if (iItems >= 0) {
        lpiArray = (int*) safemalloc (iItems * sizeof(int));
        if(Header_GetOrderArray(handle, iItems, lpiArray)) {
            EXTEND(SP, iItems);
            for (int i = 0; i < iItems; i++)
                XST_mIV(i, lpiArray[i]);
            safefree (lpiArray);
            XSRETURN(iItems);
        }
        else {
            safefree (lpiArray);
            XSRETURN_UNDEF;
        }
    } else {
        XSRETURN_UNDEF;
    }
#line 601 "Header.c"
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_GetUnicodeFormat); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_GetUnicodeFormat)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 335 "Header.xs"
    RETVAL = Header_GetUnicodeFormat(handle);
#line 629 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_HitTest); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_HitTest)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "handle, x, y");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
	LONG	x = (LONG)SvIV(ST(1))
;
	LONG	y = (LONG)SvIV(ST(2))
;
#line 351 "Header.xs"
    HDHITTESTINFO ht;
#line 653 "Header.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 353 "Header.xs"
    ZeroMemory(&ht, sizeof(HDHITTESTINFO));
    ht.pt.x = x;
    ht.pt.y = y;
    if(SendMessage(handle, HDM_HITTEST, 0, (LPARAM) &ht) == -1) {
        XSRETURN_IV(-1);
    } else {
        if(GIMME == G_ARRAY) {
            EXTEND(SP, 2);
            XST_mIV(0, (long) ht.iItem);
            XST_mIV(1, (long) ht.flags);
            XSRETURN(2);
        } else {
            XSRETURN_IV((long) ht.iItem);
        }
    }
#line 680 "Header.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__Header_InsertItem); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_InsertItem)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "handle, ...");
    {
	HWND	handle;
#line 385 "Header.xs"
    HDITEM Item;
    int index;
#line 698 "Header.c"
	LRESULT	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 388 "Header.xs"
    ZeroMemory(&Item, sizeof(HDITEM));
    index = Header_GetItemCount(handle) + 1;
    Item.fmt = HDF_LEFT;
    SwitchBit(Item.mask, HDI_FORMAT, 1);
    ParseHeaderItemOptions(NOTXSCALL sp, mark, ax, items, 1, &Item, &index);
    RETVAL = Header_InsertItem(handle, index, &Item);
#line 718 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_OrderToIndex); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_OrderToIndex)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, order");
    {
	HWND	handle;
	int	order = (int)SvIV(ST(1))
;
	int	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 407 "Header.xs"
    RETVAL = Header_OrderToIndex(handle,order);
#line 750 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_SetImageList); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_SetImageList)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, himl");
    {
	HWND	handle;
	HIMAGELIST	himl;
	HIMAGELIST	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

    if(SvROK(ST(1))) {
        SV** out=hv_fetch((HV*)SvRV(ST(1)), "-handle", 7, 0);
        if(out != NULL)
            himl = INT2PTR(HIMAGELIST,SvIV(*out));
        else
            himl = NULL;
    } else
       himl = INT2PTR(HIMAGELIST,SvIV(ST(1)))
;
#line 422 "Header.xs"
    RETVAL = (HIMAGELIST) Header_SetImageList(handle, himl);
#line 791 "Header.c"
	XSprePUSH;
	PUSHi(PTR2IV(RETVAL));
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_SetItem); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_SetItem)
{
    dVAR; dXSARGS;
    if (items < 2)
       croak_xs_usage(cv,  "handle, index, ...");
    {
	HWND	handle;
	int	index = (int)SvIV(ST(1))
;
#line 436 "Header.xs"
    HDITEM Item;
#line 811 "Header.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 438 "Header.xs"
    ZeroMemory(&Item, sizeof(HDITEM));
    ParseHeaderItemOptions(NOTXSCALL sp, mark, ax, items, 1, &Item, &index);
    RETVAL = Header_SetItem(handle, index, &Item);
#line 828 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_SetOrderArray); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_SetOrderArray)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "handle, ...");
    {
	HWND	handle;
#line 451 "Header.xs"
    int * lpiArray;
#line 846 "Header.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 453 "Header.xs"
    lpiArray = (int *) safemalloc (items * sizeof(int));
    for (int i = 1; i < items; i++)
        lpiArray[i] = (int)SvIV(ST(i));
    RETVAL = Header_SetOrderArray(handle, items-1, &lpiArray[1]);
    safefree (lpiArray);
#line 865 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_SetUnicodeFormat); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_SetUnicodeFormat)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, flag");
    {
	HWND	handle;
	BOOL	flag = (BOOL)SvIV(ST(1))
;
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 469 "Header.xs"
    RETVAL = Header_SetUnicodeFormat(handle, flag);
#line 897 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_ChangeItem); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_ChangeItem)
{
    dVAR; dXSARGS;
    if (items < 2)
       croak_xs_usage(cv,  "handle, index, ...");
    {
	HWND	handle;
	int	index = (int)SvIV(ST(1))
;
#line 487 "Header.xs"
    HDITEM Item;
#line 917 "Header.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 489 "Header.xs"
    ZeroMemory(&Item, sizeof(HDITEM));
    if(Header_GetItem(handle, index, &Item)) {
        ParseHeaderItemOptions(NOTXSCALL sp, mark, ax, items, 1, &Item, &index);
        SwitchBit(Item.mask, HDI_FORMAT, 1);
        RETVAL = Header_SetItem(handle, index, &Item);
    } else {
        RETVAL = 0;
    }
#line 939 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__Header_Clear); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__Header_Clear)
{
    dVAR; dXSARGS;
    dXSI32;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
#line 513 "Header.xs"
    int i;
#line 958 "Header.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 515 "Header.xs"
    RETVAL = TRUE;
    for(i = Header_GetItemCount(handle); i > 0; i--) {
        if(!Header_DeleteItem(handle, i)) RETVAL = FALSE;
    }
#line 976 "Header.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef __cplusplus
extern "C" {
#endif
XS_EXTERNAL(boot_Win32__GUI__Header); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Win32__GUI__Header)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

    {
        CV * cv;

        newXS_deffile("Win32::GUI::Header::CreateDragImage", XS_Win32__GUI__Header_CreateDragImage);
        newXS_deffile("Win32::GUI::Header::DeleteItem", XS_Win32__GUI__Header_DeleteItem);
        newXS_deffile("Win32::GUI::Header::GetImageList", XS_Win32__GUI__Header_GetImageList);
        newXS_deffile("Win32::GUI::Header::GetItem", XS_Win32__GUI__Header_GetItem);
        cv = newXS_deffile("Win32::GUI::Header::Count", XS_Win32__GUI__Header_GetItemCount);
        XSANY.any_i32 = 1;
        cv = newXS_deffile("Win32::GUI::Header::GetItemCount", XS_Win32__GUI__Header_GetItemCount);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Win32::GUI::Header::GetItemRect", XS_Win32__GUI__Header_GetItemRect);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Win32::GUI::Header::ItemRect", XS_Win32__GUI__Header_GetItemRect);
        XSANY.any_i32 = 1;
        newXS_deffile("Win32::GUI::Header::GetOrderArray", XS_Win32__GUI__Header_GetOrderArray);
        newXS_deffile("Win32::GUI::Header::GetUnicodeFormat", XS_Win32__GUI__Header_GetUnicodeFormat);
        newXS_deffile("Win32::GUI::Header::HitTest", XS_Win32__GUI__Header_HitTest);
        newXS_deffile("Win32::GUI::Header::InsertItem", XS_Win32__GUI__Header_InsertItem);
        newXS_deffile("Win32::GUI::Header::OrderToIndex", XS_Win32__GUI__Header_OrderToIndex);
        newXS_deffile("Win32::GUI::Header::SetImageList", XS_Win32__GUI__Header_SetImageList);
        newXS_deffile("Win32::GUI::Header::SetItem", XS_Win32__GUI__Header_SetItem);
        newXS_deffile("Win32::GUI::Header::SetOrderArray", XS_Win32__GUI__Header_SetOrderArray);
        newXS_deffile("Win32::GUI::Header::SetUnicodeFormat", XS_Win32__GUI__Header_SetUnicodeFormat);
        newXS_deffile("Win32::GUI::Header::ChangeItem", XS_Win32__GUI__Header_ChangeItem);
        cv = newXS_deffile("Win32::GUI::Header::Clear", XS_Win32__GUI__Header_Clear);
        XSANY.any_i32 = 0;
        cv = newXS_deffile("Win32::GUI::Header::Reset", XS_Win32__GUI__Header_Clear);
        XSANY.any_i32 = 1;
    }
#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

#ifdef __cplusplus
}
#endif
