The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#############################################################################
## Name:        viface/TextCtrlIface.xsp
## Purpose:     XS++ for wxTextCtrlIface
## Author:      Mark Dootson
## Modified by:
## Created:     21/11/2011
## RCS-ID:      $Id:$
## Copyright:   (c) 2011 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

%file{xspp/TextCtrlIface.h};

%module{Wx};

#if WXPERL_W_VERSION_GE( 2, 9, 2 )

%typemap{wxTextCtrlIface*}{simple};
%typemap{const wxTextAttr&}{reference};

%name{Wx::TextCtrlIface} class wxTextCtrlIface
{
 
	wxString GetValue() const;
	void SetValue( const wxString& value );
	void ChangeValue( const wxString& value );
	wxString GetRange( long from, long to ) const;
	
	void WriteText( const wxString& text );
	void AppendText( const wxString& text ); 	
	
    bool IsEmpty();
    
    void Clear();
	void Replace( long from, long to, const wxString& value );
	void Remove( long from, long to );
	void RemoveSelection();

	void Copy();
	void Cut();
	void Paste();
	bool CanCopy() const;
	bool CanCut() const;
	bool CanPaste() const;
	void Undo();
	void Redo();
	bool CanUndo() const;
	bool CanRedo() const;

	void SetInsertionPoint( long pos );
	void SetInsertionPointEnd();
	long GetInsertionPoint() const;
	long GetLastPosition() const;
    
    void SetSelection( long from, long to );
	void SelectAll();
	bool HasSelection() const;    
	wxString GetStringSelection() const;
	
##  void GetSelection(long *from, long *to);
        
	bool AutoCompleteFileNames();
    
    bool AutoComplete( const wxArrayString& choices );
##	bool AutoComplete( wxTextCompleter *completer);
    
	bool IsEditable() const;	
	void SetEditable( bool editable ); 
    
	void SetMaxLength( unsigned long len );

	bool SetHint(const wxString& hint);
	wxString GetHint() const;

	bool SetMargins(const wxPoint& pt);
    wxPoint GetMargins() const;
    
    /* implement wxTextAreaBase */
    
	int GetLineLength( long lineNo ) const;
	wxString GetLineText( long lineNo ) const;
	int GetNumberOfLines() const;

#if defined(WXPERL_IN_RICHTEXTCTRL)
    bool LoadFile( const wxString& file, int fileType = wxTEXT_TYPE_ANY );
    bool SaveFile( const wxString& file = wxEmptyString, int fileType = wxTEXT_TYPE_ANY );
#endif

	bool IsModified() const;
	void MarkDirty();
	void DiscardEdits();
	void SetModified( bool modified );
    
#if defined(WXPERL_IN_SEARCHCTRL)

    bool SetStyle( long start, long end, const wxTextAttr& style );
##  bool GetStyle(long position, wxTextAttr& style) = 0;

#endif

#if !defined(WXPERL_IN_RICHTEXTCTRL)
	bool SetDefaultStyle( const wxTextAttr& style );
#endif
	
	const wxTextAttr& GetDefaultStyle() const;


	long XYToPosition( long x, long y ) const;
##  bool PositionToXY(long pos, long *x, long *y) const;
	void ShowPosition(long pos);
	
##  wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
##  wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const;

};

%{

void
wxTextCtrlIface::GetSelection()
  PREINIT:
    long from;
    long to;
  PPCODE:
    THIS->GetSelection( &from, &to );
    EXTEND( SP, 2 );
    PUSHs( sv_2mortal( newSViv( from ) ) );
    PUSHs( sv_2mortal( newSViv( to ) ) );

%}

#if defined(WXPERL_IN_SEARCHCTRL)

%{
void
wxTextCtrlIface::GetStyle( position )
    long position
  PPCODE:
    wxTextAttr attr;
    bool retval = THIS->GetStyle( position, attr );
    EXTEND( SP, 2 );
    PUSHs( newSViv( retval ) );
    PUSHs( retval ? wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                                           new wxTextAttr( attr ),
                                           "Wx::TextAttr" ) :
                    &PL_sv_undef );
%}

#endif

%{
void
wxTextCtrlIface::PositionToXY( pos )
    long pos
  PREINIT:
    long x;
    long y;
  PPCODE:
    THIS->PositionToXY( pos, &x, &y );
    EXTEND( SP, 2 );
    PUSHs( sv_2mortal( newSViv( x ) ) );
    PUSHs( sv_2mortal( newSViv( y ) ) );

%}


%{

void
wxTextCtrlIface::HitTest( pt )
    wxPoint pt
  PPCODE:
    long col, row;
    wxTextCtrlHitTestResult res = THIS->HitTest( pt, &col, &row );

    EXTEND( SP, 3 );
    PUSHs( sv_2mortal( newSViv( res ) ) );
    PUSHs( sv_2mortal( newSViv( col ) ) );
    PUSHs( sv_2mortal( newSViv( row ) ) );

%}

#endif

%file{-};