The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#############################################################################
## Name:        XS/OwnerDrawnComboBox.xsp
## Purpose:     XS++ for Wx::OwnerDrawnComboBox
## Author:      Mattia Barbon
## Modified by:
## Created:     13/08/2007
## RCS-ID:      $Id: OwnerDrawnComboBox.xsp 3010 2011-02-20 16:27:27Z mbarbon $
## Copyright:   (c) 2007, 2010-2011 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

%module{Wx};

#if WXPERL_W_VERSION_GE( 2, 7, 2 )

#include <wx/odcombo.h>

%typemap{wxOwnerDrawnComboBox*}{simple};
%typemap{wxPlOwnerDrawnComboBox*}{simple};

%name{Wx::OwnerDrawnComboBox} class wxOwnerDrawnComboBox
{
    int GetWidestItemWidth();
    int GetWidestItem();
};

# the second regex is an horrible hack to solve ambiguity; maybe should
# use real base classes instead of this hack?
INCLUDE_COMMAND: $^X -pe "s/ItemContainerImmutable/OwnerDrawnComboBox/g;s/->(?=IsEmpty|GetStringSelection)/->wxItemContainerImmutable::/" XS/ItemContainerImmutable.xs

INCLUDE_COMMAND: $^X -pe "s/ItemContainer/OwnerDrawnComboBox/g" XS/ItemContainer.xs

%file{xspp/odcombo.h};
%{

#include "cpp/v_cback.h"

// void METH(wxDC&, const wxRect&, int, int)
#define DEC_V_CBACK_VOID__WXDC_WXRECT_INT_INT_const( METHOD ) \
    void METHOD( wxDC& p1, const wxRect& p2, int p3, int p4 ) const

#define DEF_V_CBACK_VOID__WXDC_WXRECT_INT_INT_const( CLASS, BASE, METHOD )\
    void CLASS::METHOD( wxDC& p1, const wxRect& p2, int p3, int p4 ) const   \
    {                                                                        \
        dTHX;                                                                \
        if( wxPliFCback( aTHX_ &m_callback, #METHOD ) )                      \
        {                                                                    \
            wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback,              \
                                             G_SCALAR|G_DISCARD,             \
                                             "Qoii", &p1,                    \
                                             new wxRect( p2 ), "Wx::Rect",   \
                                             p3, p4 ) );                     \
            return;                                                          \
        } else                                                               \
            BASE::METHOD( p1, p2, p3, p4 );                                  \
    }

class wxPlOwnerDrawnComboBox : public wxOwnerDrawnComboBox {
    WXPLI_DECLARE_DYNAMIC_CLASS( wxPlOwnerDrawnComboBox );
    WXPLI_DECLARE_V_CBACK();
public:
    WXPLI_DEFAULT_CONSTRUCTOR( wxPlOwnerDrawnComboBox,
                               "Wx::OwnerDrawnComboBox", true );
    WXPLI_CONSTRUCTOR_9( wxPlOwnerDrawnComboBox, "Wx::OwnerDrawnComboBox",
                         true,
                         wxWindow*, wxWindowID, const wxString&,
                         const wxPoint&, const wxSize&, const wxArrayString&,
                         long, const wxValidator&, const wxString& );

    DEC_V_CBACK_WXCOORD__SIZET_const( OnMeasureItem );
    DEC_V_CBACK_WXCOORD__SIZET_const( OnMeasureItemWidth );
    DEC_V_CBACK_VOID__WXDC_WXRECT_INT_INT_const( OnDrawItem );
    DEC_V_CBACK_VOID__WXDC_WXRECT_INT_INT_const( OnDrawBackground );
};

DEF_V_CBACK_WXCOORD__SIZET_const( wxPlOwnerDrawnComboBox, wxOwnerDrawnComboBox,
                                  OnMeasureItem ); 
DEF_V_CBACK_WXCOORD__SIZET_const( wxPlOwnerDrawnComboBox, wxOwnerDrawnComboBox,
                                  OnMeasureItemWidth ); 
DEF_V_CBACK_VOID__WXDC_WXRECT_INT_INT_const( wxPlOwnerDrawnComboBox,
                                             wxOwnerDrawnComboBox,
                                             OnDrawItem );
DEF_V_CBACK_VOID__WXDC_WXRECT_INT_INT_const( wxPlOwnerDrawnComboBox,
                                             wxOwnerDrawnComboBox,
                                             OnDrawBackground );

WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlOwnerDrawnComboBox, wxOwnerDrawnComboBox );
%}
%file{-};

#include "xspp/odcombo.h"

%name{Wx::PlOwnerDrawnComboBox} class wxPlOwnerDrawnComboBox
{
%{
void
new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_VOIDM_REDISP( newDefault )
        MATCH_ANY_REDISP( newFull )
    END_OVERLOAD( "Wx::PlOwnerDrawnComboBox::new" )
%}

    %name{newDefault} wxPlOwnerDrawnComboBox()
        %code{% RETVAL = new wxPlOwnerDrawnComboBox( CLASS );
                wxPli_create_evthandler( aTHX_ RETVAL, CLASS );
                %};
    %name{newFull} wxPlOwnerDrawnComboBox( wxWindow *parent,
                                           wxWindowID id,
                                           const wxString& value,
                                           const wxPoint& pos,
                                           const wxSize& size,
                                           const wxArrayString& choices,
                                           long style = 0,
                                           const wxValidator& validator = wxDefaultValidatorPtr,
                                           const wxString& name = wxEmptyString)
        %code{% RETVAL = new wxPlOwnerDrawnComboBox( CLASS, parent, id, value,
                                                     pos, size, choices, style,
                                                     *validator, name );
                wxPli_create_evthandler( aTHX_ RETVAL, CLASS );
                %};

    bool Create( wxWindow *parent,
                 wxWindowID id,
                 const wxString& value = wxEmptyString,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 const wxArrayString& choices,
                 long style = 0,
                 const wxValidator& validator = wxDefaultValidatorPtr,
                 const wxString& name = wxEmptyString );
};

#endif