#############################################################################
## 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,v 1.5 2006/11/25 14:30:54 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
#############################################################################

#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 );
    ## // thread KO
    ~wxRichTextRange();

    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 );
    ## // thread KO
    ~wxTextAttrEx();

    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;
};

## 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 );
    %name{newFull} wxRichTextAttr
        ( const wxColour& colText, const wxColour& colBack = wxNullColourPtr,
          wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT );
    ## // thread KO
    ~wxRichTextAttr();

    wxFont CreateFont() const;
    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( int fontStyle );
    void SetFontWeight( int 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;
    int GetFontStyle() const;
    int GetFontWeight() const;
    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 )
        MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_wcol_wcol_n, newFull, 2 )
    END_OVERLOAD( Wx::RichTextAttr::new )

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

%}