The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#############################################################################
## Name:        XS/GraphicsRenderer.xsp
## Purpose:     XS for Wx::GraphicsRenderer
## Author:      Mattia Barbon
## Modified by:
## Created:     30/09/2007
## RCS-ID:      $Id: GraphicsRenderer.xsp 2952 2010-08-15 10:38:47Z mbarbon $
## Copyright:   (c) 2007, 2010 Klaas Hartmann
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

%module{Wx};

%loadplugin{build::Wx::XSP::Overload};

#if wxUSE_GRAPHICS_CONTEXT

#include <wx/graphics.h>

## DECLARE_OVERLOAD( wmdc, Wx::MemoryDC )
## DECLARE_OVERLOAD( wwdc, Wx::WindowDC )
## DECLARE_OVERLOAD( wpdc, Wx::PrinterDC )

#if WXPERL_W_VERSION_GE( 2, 9, 1 )

%typemap{wxColour}{parsed}{%wxColour%};

%name{Wx::GraphicsGradientStop} class wxGraphicsGradientStop
{
public:
    wxGraphicsGradientStop( wxColour col = wxTransparentColour,
                            float pos = 0.);

%{
static void
wxGraphicsGradientStop::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );

## // thread OK
void
wxGraphicsGradientStop::DESTROY()
  CODE:
    wxPli_thread_sv_unregister( aTHX_ "Wx::GraphicsGradientStop", THIS, ST(0) );
    delete THIS;
%}

    const wxColour& GetColour() const;
    void SetColour( const wxColour& col );

    float GetPosition() const;
    void SetPosition( float pos );
};

%typemap{const wxGraphicsGradientStop&}{reference};

%name{Wx::GraphicsGradientStops} class wxGraphicsGradientStops
{
public:
    wxGraphicsGradientStops( wxColour startCol = wxTransparentColour,
                             wxColour endCol = wxTransparentColour );

%{
static void
wxGraphicsGradientStops::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );

## // thread OK
void
wxGraphicsGradientStops::DESTROY()
  CODE:
    wxPli_thread_sv_unregister( aTHX_ "Wx::GraphicsGradientStop", THIS, ST(0) );
    delete THIS;
%}

    // Add a stop in correct order.
    %name{AddStop} void Add( const wxGraphicsGradientStop& stop ) %Overload;
    %name{AddColour} void Add( wxColour col, float pos ) %Overload;

    // Get the number of stops.
    unsigned GetCount() const;

    // Return the stop at the given index (which must be valid).
    const wxGraphicsGradientStop& Item( unsigned n ) const;

    // Get/set start and end colours.
    void SetStartColour( wxColour col );
    const wxColour& GetStartColour() const;
    void SetEndColour( wxColour col );
    const wxColour& GetEndColour() const;
};

%typemap{const wxGraphicsGradientStops&}{reference};

#endif

%name{Wx::GraphicsRenderer} class wxGraphicsRenderer
{
%{
wxGraphicsRenderer*
GetDefaultRenderer()
  CODE:
    RETVAL = wxGraphicsRenderer::GetDefaultRenderer();
  OUTPUT: RETVAL

void
CreateContext( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_REDISP( wxPliOvl_wwin, CreateFromWindow )   
#if defined(__WXMSW__) || WXPERL_W_VERSION_GE( 2, 9, 0 )       
        MATCH_REDISP( wxPliOvl_wmdc, CreateFromMemoryDC)
#endif     
#if wxPERL_USE_PRINTING_ARCHITECTURE && WXPERL_W_VERSION_GE( 2, 9, 0 )     
        MATCH_REDISP( wxPliOvl_wpdc, CreateFromPrinterDC)
#endif                  
        MATCH_REDISP( wxPliOvl_wwdc, CreateFromWindowDC )
    END_OVERLOAD( "Wx::GraphicsRenderer::CreateContext" )

%}

    %name{CreateFromWindowDC} wxGraphicsContext* CreateContext( const wxWindowDC& dc );
    %name{CreateFromWindow} wxGraphicsContext* CreateContext( wxWindow* window );
#if defined(__WXMSW__) || WXPERL_W_VERSION_GE( 2, 9, 0 )           
    %name{CreateFromMemoryDC} wxGraphicsContext* CreateContext( const wxMemoryDC& dc );
#endif
#if wxPERL_USE_PRINTING_ARCHITECTURE && WXPERL_W_VERSION_GE( 2, 9, 0 )     
    %name{CreateFromPrinterDC} wxGraphicsContext* CreateContext( const wxPrinterDC& dc );
#endif
    wxGraphicsContext* CreateMeasuringContext();
    const wxGraphicsPath& CreatePath();
    const wxGraphicsMatrix& CreateMatrix( wxDouble a=1.0, wxDouble b=0.0,
                                          wxDouble c=0.0, wxDouble d=1.0,
                                          wxDouble tx=0.0, wxDouble ty=0.0 );
    const wxGraphicsPen& CreatePen( const wxPen& pen );
    const wxGraphicsBrush& CreateBrush( const wxBrush& brush );

#if WXPERL_W_VERSION_LT( 2, 9, 1 )
    const wxGraphicsBrush& CreateLinearGradientBrush( wxDouble x1, wxDouble y1,
                                                      wxDouble x2, wxDouble y2,
                                                      const wxColour&c1, const wxColour&c2 );
    const wxGraphicsBrush& CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
                                                      wxDouble xc, wxDouble yc,
                                                      wxDouble radius,
                                                      const wxColour &oColor, const wxColour &cColor );
#else
    const wxGraphicsBrush& CreateLinearGradientBrush( wxDouble x1, wxDouble y1,
                                                      wxDouble x2, wxDouble y2,
                                                      const wxGraphicsGradientStops& stops );
    const wxGraphicsBrush& CreateRadialGradientBrush( wxDouble xo, wxDouble yo,
                                                      wxDouble xc, wxDouble yc,
                                                      wxDouble radius,
                                                      const wxGraphicsGradientStops& stops );
#endif

#define wxBLACKPtr (wxColour*)wxBLACK
    const wxGraphicsFont& CreateFont( const wxFont& font,
                                      const wxColour& col = wxBLACKPtr );
};

#endif