The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#############################################################################
## Name:        ext/richtext/XS/RichTextAttr.xsp
## Purpose:     XS++ for Wx::RichTextAttr and Wx::TextAttrEx
## Author:      Mattia Barbon
## Modified by:
## Created:     05/11/2006
## RCS-ID:      $Id: RichTextAttr.xsp 3035 2011-03-13 21:57:38Z mbarbon $
## Copyright:   (c) 2006-2011 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

#include <wx/event.h>
#include <wx/richtext/richtextbuffer.h>

%module{Wx};

%name{Wx::RichTextRange} class wxRichTextRange
{
    %name{newDefault} wxRichTextRange();
    %name{newFromTo} wxRichTextRange( long start, long end );
    %name{newCopy} wxRichTextRange( const wxRichTextRange& range );

%{
static void
wxRichTextRange::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}
    ## // thread OK
    ~wxRichTextRange()
        %code{% wxPli_thread_sv_unregister( aTHX_ "Wx::RichTextRange", THIS, ST(0) );
                delete THIS;
                %};

    void SetRange( long start, long end );
    void SetStart( long start );
    long GetStart() const;

    void SetEnd( long end );
    long GetEnd() const;

    bool IsOutside( const wxRichTextRange& range ) const;
    bool IsWithin( const wxRichTextRange& range ) const;

    bool Contains( long pos ) const;
    bool LimitTo( const wxRichTextRange& range );
    long GetLength() const;
};

## DECLARE_OVERLOAD( wrtr, Wx::RichTextRange )

%{

void
wxRichTextRange::new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_VOIDM_REDISP( newDefault )
        MATCH_REDISP( wxPliOvl_n_n, newFromTo )
        MATCH_REDISP( wxPliOvl_wrtr, newCopy )
    END_OVERLOAD( Wx::RichTextRange::new )

%}

%name{Wx::TextAttrEx} class wxTextAttrEx
{
    %name{newDefault} wxTextAttrEx();
    %name{newCopy} wxTextAttrEx( const wxTextAttrEx& attr );
    %name{newAttr} wxTextAttrEx( const wxTextAttr& attr );

%{
static void
wxTextAttrEx::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}
    ## // thread OK
    ~wxTextAttrEx()
        %code{% wxPli_thread_sv_unregister( aTHX_ "Wx::TextAttrEx", THIS, ST(0) );
                delete THIS;
                %};

    void SetCharacterStyleName( const wxString& name );
    void SetParagraphStyleName( const wxString& name );
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    void SetListStyleName( const wxString& name );
#endif
    void SetParagraphSpacingAfter( int spacing );
    void SetParagraphSpacingBefore( int spacing );
    void SetLineSpacing( int spacing );
    void SetBulletStyle( int style );
    void SetBulletNumber( int n );
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    void SetBulletText( const wxString& text );
    void SetBulletName( const wxString& name );
    void SetBulletFont( const wxString& bulletFont );
    void SetURL( const wxString& url );
    void SetPageBreak( bool pageBreak = true );
#endif

    const wxString& GetCharacterStyleName() const;
    const wxString& GetParagraphStyleName() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    const wxString& GetListStyleName() const;
#endif
    int GetParagraphSpacingAfter() const;
    int GetParagraphSpacingBefore() const;
    int GetLineSpacing() const;
    int GetBulletStyle() const;
    int GetBulletNumber() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    const wxString& GetBulletText() const;
    const wxString& GetBulletName() const;
    const wxString& GetBulletFont() const;
    const wxString& GetURL() const;
#endif

#if WXPERL_W_VERSION_LT( 2, 8, 0 )
    bool HasWeight() const;
    bool HasSize() const;
    bool HasItalic() const;
    bool HasUnderlined() const;
    bool HasFaceName() const;
#endif

    bool HasParagraphSpacingAfter() const;
    bool HasParagraphSpacingBefore() const;
    bool HasLineSpacing() const;
    bool HasCharacterStyleName() const;
    bool HasParagraphStyleName() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    bool HasListStyleName() const;
#endif
    bool HasBulletStyle() const;
    bool HasBulletNumber() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    bool HasBulletText() const;
    bool HasBulletName() const;
    bool HasURL() const;
    bool HasPageBreak() const;
#endif

    bool IsCharacterStyle() const;
    bool IsParagraphStyle() const;

    bool IsDefault() const;

#if WXPERL_W_VERSION_LT( 2, 9, 0 ) && WXPERL_W_VERSION_GE( 2, 8, 0 )
    int GetOutlineLevel() const;
    bool HasOutlineLevel() const;
    void SetOutlineLevel( int level );

    int GetTextEffects() const;
    bool HasTextEffects() const;
    void SetTextEffects( int effects );

    int GetTextEffectFlags() const;
    bool HasTextEffect( int effect ) const;
    void SetTextEffectFlags( int effects );
#endif
};

## DECLARE_OVERLOAD( wtae, Wx::TextAttrEx )
## DECLARE_OVERLOAD( wtat, Wx::TextAttr )

%{

void
wxTextAttrEx::new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_VOIDM_REDISP( newDefault )
        MATCH_REDISP( wxPliOvl_wtae, newCopy )
        MATCH_REDISP( wxPliOvl_wtat, newAttr )
    END_OVERLOAD( Wx::TextAttrEx::new )

%}

%name{Wx::RichTextAttr} class wxRichTextAttr
{
    %name{newDefault} wxRichTextAttr();
    %name{newCopy} wxRichTextAttr( const wxRichTextAttr& attr );
    %name{newAttrEx} wxRichTextAttr( const wxTextAttrEx& attr );
    %name{newAttr} wxRichTextAttr( const wxTextAttr& attr );
#if WXPERL_W_VERSION_GE( 2, 9, 0 ) && WXPERL_W_VERSION_LT( 2, 9, 2 )
    %name{newFull} wxRichTextAttr
        ( const wxColour& colText, const wxColour& colBack = wxNullColourPtr,
          const wxFont& font = wxNullFontPtr,
          wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT );
#else
#if WXPERL_W_VERSION_LT( 2, 9, 0 )
    %name{newFull} wxRichTextAttr
        ( const wxColour& colText, const wxColour& colBack = wxNullColourPtr,
          wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT );
#endif
#endif
%{
static void
wxRichTextAttr::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}
    ## // thread OK
    ~wxRichTextAttr()
        %code{% wxPli_thread_sv_unregister( aTHX_ "Wx::RichTextAttr", THIS, ST(0) );
                delete THIS;
                %};

#if WXPERL_W_VERSION_LT( 2, 9, 0 )
    wxFont CreateFont() const;
#endif
    bool GetFontAttributes( const wxFont& font );

    void SetTextColour( const wxColour& colText );
    void SetBackgroundColour( const wxColour& colBack );
    void SetAlignment( wxTextAttrAlignment alignment );
    void SetTabs( const wxArrayInt& tabs );
    void SetLeftIndent( int indent, int subIndent = 0 );
    void SetRightIndent( int indent );

    void SetFontSize( int pointSize );
    void SetFontStyle( wxFontStyle fontStyle );
    void SetFontWeight( wxFontWeight fontWeight );
    void SetFontFaceName( const wxString& faceName );
    void SetFontUnderlined( bool underlined );

    void SetFlags( long flags );

    void SetCharacterStyleName( const wxString& name );
    void SetParagraphStyleName( const wxString& name );
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    void SetListStyleName( const wxString& name );
#endif
    void SetParagraphSpacingAfter( int spacing );
    void SetParagraphSpacingBefore( int spacing );
    void SetLineSpacing( int spacing );
    void SetBulletStyle( int style );
    void SetBulletNumber( int n );
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    void SetBulletText( const wxString& text );
    void SetBulletFont( const wxString& bulletFont );
    void SetBulletName( const wxString& name );
    void SetURL( const wxString& url );
    void SetPageBreak( bool pageBreak = true );
#endif

    const wxColour& GetTextColour() const;
    const wxColour& GetBackgroundColour() const;
    wxTextAttrAlignment GetAlignment() const;
    long GetLeftIndent() const;
    long GetLeftSubIndent() const;
    long GetRightIndent() const;
    long GetFlags() const;

    int GetFontSize() const;
#if WXPERL_W_VERSION_GE( 2, 9, 0 )
    wxFontStyle GetFontStyle() const;
    wxFontWeight GetFontWeight() const;
#else
    int GetFontStyle() const;
    int GetFontWeight() const;
#endif
    bool GetFontUnderlined() const;
    const wxString& GetFontFaceName() const;

    const wxString& GetCharacterStyleName() const;
    const wxString& GetParagraphStyleName() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    const wxString& GetListStyleName() const;
#endif
    int GetParagraphSpacingAfter() const;
    int GetParagraphSpacingBefore() const;
    int GetLineSpacing() const;
    int GetBulletStyle() const;
    int GetBulletNumber() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    const wxString& GetBulletText() const;
    const wxString& GetBulletFont() const;
    const wxString& GetBulletName() const;
    const wxString& GetURL() const;
#endif

    bool HasTextColour() const;
    bool HasBackgroundColour() const;
    bool HasAlignment() const;
    bool HasTabs() const;
    bool HasLeftIndent() const;
    bool HasRightIndent() const;
#if WXPERL_W_VERSION_LT( 2, 8, 0 )
    bool HasWeight() const;
    bool HasSize() const;
    bool HasItalic() const;
    bool HasUnderlined() const;
    bool HasFaceName() const;
#endif
    bool HasFont() const;

    bool HasParagraphSpacingAfter() const;
    bool HasParagraphSpacingBefore() const;
    bool HasLineSpacing() const;
    bool HasCharacterStyleName() const;
    bool HasParagraphStyleName() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    bool HasListStyleName() const;
#endif
    bool HasBulletStyle() const;
    bool HasBulletNumber() const;
#if WXPERL_W_VERSION_GE( 2, 7, 2 )
    bool HasBulletText() const;
    bool HasBulletName() const;
    bool HasURL() const;
    bool HasPageBreak() const;
#endif

    bool IsCharacterStyle() const;
    bool IsParagraphStyle() const;

    bool IsDefault() const;
};

## DECLARE_OVERLOAD( wrta, Wx::RichTextAttr )

%{

void
wxRichTextAttr::new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_VOIDM_REDISP( newDefault )
        MATCH_REDISP( wxPliOvl_wrta, newCopy )
        MATCH_REDISP( wxPliOvl_wtae, newAttrEx )
        MATCH_REDISP( wxPliOvl_wtat, newAttr )
#if WXPERL_W_VERSION_LT( 2, 9, 2 )
        MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wcol_wcol_n, newFull, 2 )
#endif
    END_OVERLOAD( Wx::RichTextAttr::new )

void
wxRichTextAttr::GetTabs()
  PPCODE:
    const wxArrayInt& tabs = THIS->GetTabs();
    PUTBACK;
    wxPli_intarray_push( aTHX_ tabs );
    SPAGAIN;

%}