#############################################################################
## Name:        XS/VListBox.xsp
## Purpose:     XS++ for Wx::VListBox
## Author:      Mattia Barbon
## Modified by:
## Created:     18/09/2006
## RCS-ID:      $Id: VListBox.xsp,v 1.2 2006/10/01 13:03:56 mbarbon Exp $
## Copyright:   (c) 2006 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};

%typemap{wxVListBox*}{simple};
%typemap{wxPlVListBox*}{simple};

#if WXPERL_W_VERSION_GE( 2, 5, 0 )

%{
#include <wx/vlbox.h>
%}

%name{Wx::VListBox} class wxVListBox
{
##    %name{newDefault} wxVListBox()
##        %code{% RETVAL = new wxVListBox();
##                wxPli_create_evtahndler( aTHX_ RETVAL, CLASS );
##             %};
##    %name{newFull} wxVListBox( wxWindow *parent,
##                               wxWindowID id = wxID_ANY,
##                               const wxPoint& pos = wxDefaultPosition,
##                               const wxSize& size = wxDefaultSize,
##                               long style = 0,
##                               const wxString& name = wxVListBoxNameStr )
##        %code{% RETVAL = new wxListBox( parent, id, pos, size, style, name );
##                wxPli_create_evthandler( aTHX_ RETVAL, CLASS );
##             %};

    bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 long style = 0,
                 const wxString& name = wxVListBoxNameStr );

    bool IsCurrent(size_t item) const;
    bool IsSelected(size_t item) const;
    size_t GetSelectedCount() const;
    wxPoint GetMargins() const;
    const wxColour& GetSelectionBackground() const;
    void SetItemCount( size_t count );
    void Clear();
    void SetSelection( int selection );
    bool Select( size_t item, bool select = true );
    bool SelectRange( size_t from, size_t to );
    void Toggle( size_t item );
    bool SelectAll();
    bool DeselectAll();
    void SetMargins( wxCoord x, wxCoord y );
    void SetSelectionBackground( const wxColour& col );
};

%{

##void
##new( ... )
##  PPCODE:
##    BEGIN_OVERLOAD()
##        MATCH_VOIDM_REDISP( newDefault )
##        MATCH_ANY_REDISP( newFull )
##    END_OVERLOAD( "Wx::VListBox::new" )

void
wxVListBox::GetFirstSelected()
  CODE:
    unsigned long cookie;
    int ret = THIS->GetFirstSelected( cookie );
    EXTEND( SP, 2 );
    PUSHs( sv_2mortal( newSViv( ret ) ) );
    PUSHs( sv_2mortal( newSViv( cookie ) ) );

void
wxVListBox::GetNextSelected( unsigned long cookie )
  CODE:
    int ret = THIS->GetFirstSelected( cookie );
    EXTEND( SP, 2 );
    PUSHs( sv_2mortal( newSViv( ret ) ) );
    PUSHs( sv_2mortal( newSViv( cookie ) ) );

%}

%file{cpp/vlbox.h};
%{

#include "cpp/v_cback.h"

// void METH(wxDC&, const wxRect&, size_t)
#define DEC_V_CBACK_VOID__WXDC_WXRECT_SIZET_const( METHOD ) \
    void METHOD( wxDC& p1, const wxRect& p2, size_t p3 ) const

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

class wxPlVListBox : public wxVListBox {
    WXPLI_DECLARE_DYNAMIC_CLASS( wxPlVListBox );
    WXPLI_DECLARE_V_CBACK();
public:
    WXPLI_DEFAULT_CONSTRUCTOR( wxPlVListBox, "Wx::VListBox", true );
    WXPLI_CONSTRUCTOR_6( wxPlVListBox, "Wx::VListBox", true,
                         wxWindow*, wxWindowID, const wxPoint&,
                         const wxSize&, long, const wxString& );

    DEC_V_CBACK_WXCOORD__VOID_const( EstimateTotalHeight );
    DEC_V_CBACK_WXCOORD__SIZET_const( OnMeasureItem );
    DEC_V_CBACK_VOID__WXDC_WXRECT_SIZET_const( OnDrawItem );
};

DEF_V_CBACK_WXCOORD__VOID_const( wxPlVListBox, wxVListBox,
                                 EstimateTotalHeight );
DEF_V_CBACK_WXCOORD__SIZET_const_pure( wxPlVListBox, wxVListBox,
                                       OnMeasureItem ); 
DEF_V_CBACK_VOID__WXDC_WXRECT_SIZET_const_pure( wxPlVListBox, wxVListBox,
                                                OnDrawItem );

WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPlVListBox, wxVListBox );

%}
%file{-};

%{
#include "cpp/overload.h"
#include "cpp/vlbox.h"
%}

%name{Wx::PlVListBox} class wxPlVListBox
{
    %name{newDefault} wxPlVListBox()
        %code{% RETVAL = new wxPlVListBox( CLASS ); %};
    %name{newFull} wxPlVListBox( wxWindow *parent,
                                 wxWindowID id = wxID_ANY,
                                 const wxPoint& pos = wxDefaultPosition,
                                 const wxSize& size = wxDefaultSize,
                                 long style = 0,
                                 const wxString& name = wxVListBoxNameStr )
        %code{% RETVAL = new wxPlVListBox( CLASS, parent, id, pos, size,
                                           style, name );
             %};
};



%{

void
new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_VOIDM_REDISP( newDefault )
        MATCH_ANY_REDISP( newFull )
    END_OVERLOAD( "Wx::PlVListBox::new" )

%}

#endif