Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / XS / TextCtrl.xs
1 #############################################################################
2 ## Name:        XS/TextCtrl.xs
3 ## Purpose:     XS for Wx::TextCtrl
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     29/10/2000
7 ## RCS-ID:      $Id: TextCtrl.xs 2735 2010-01-02 10:39:01Z mbarbon $
8 ## Copyright:   (c) 2000-2003, 2005-2007, 2010 Mattia Barbon
9 ## Licence:     This program is free software; you can redistribute it and/or
10 ##              modify it under the same terms as Perl itself
11 #############################################################################
12
13 %module{Wx};
14
15 #include <wx/textctrl.h>
16
17 %typemap{wxMouseEvent&}{reference};
18 %typemap{wxTextAttr*}{simple};
19 %typemap{const wxTextAttr&}{reference};
20 %typemap{wxTextAttrAlignment}{simple};
21 %typemap{const wxKeyEvent&}{reference};
22 %typemap{wxTextPos}{parsed}{%wxTextPos%};
23
24 %name{Wx::TextUrlEvent} class wxTextUrlEvent
25 {
26     wxMouseEvent& GetMouseEvent();
27     long GetURLStart();
28     long GetURLEnd();
29 };
30
31 %name{Wx::TextCtrlBase} class wxTextCtrlBase
32 {
33     wxString GetValue() const;
34 #if WXPERL_W_VERSION_GE( 2, 7, 2 )
35     bool IsEmpty();
36 #endif
37     void SetValue( const wxString& value );
38 #if WXPERL_W_VERSION_GE( 2, 7, 1 )
39     void ChangeValue( const wxString& value );
40 #endif
41     wxString GetRange( long from, long to ) const;
42     int GetLineLength( long lineNo ) const;
43     wxString GetLineText( long lineNo ) const;
44     int GetNumberOfLines() const;
45     bool IsModified() const;
46     bool IsEditable() const;
47     bool IsSingleLine() const;
48     bool IsMultiLine() const;
49     wxString GetStringSelection() const;
50     void Clear();
51     void Replace( long from, long to, const wxString& value );
52     void Remove( long from, long to );
53 #if WXPERL_W_VERSION_GE( 2, 7, 1 )
54     bool LoadFile( const wxString& file, int fileType = wxTEXT_TYPE_ANY );
55     bool SaveFile( const wxString& file = wxEmptyString,
56                    int fileType = wxTEXT_TYPE_ANY );
57 #else
58     bool LoadFile( const wxString& file );
59     bool SaveFile( const wxString& file = wxEmptyString );
60 #endif
61     void MarkDirty();
62     void DiscardEdits();
63 #if WXPERL_W_VERSION_GE( 2, 7, 0 )
64     void SetModified( bool modified );
65 #endif
66     void SetMaxLength( unsigned long len );
67     void WriteText( const wxString& text );
68     void AppendText( const wxString& text );
69     bool EmulateKeyPress( const wxKeyEvent& event );
70     bool SetStyle( long start, long end, const wxTextAttr& style );
71 ##    bool GetStyle( long position, wxTextAttr& style );
72     bool SetDefaultStyle( const wxTextAttr& style );
73     const wxTextAttr& GetDefaultStyle() const;
74     long XYToPosition( long x, long y ) const;
75     void ShowPosition(long pos);
76     void Copy();
77     void Cut();
78     void Paste();
79     bool CanCopy() const;
80     bool CanCut() const;
81     bool CanPaste() const;
82     void Undo();
83     void Redo();
84     bool CanUndo() const;
85     bool CanRedo() const;
86     void SetInsertionPoint( long pos );
87     void SetInsertionPointEnd();
88     long GetInsertionPoint() const;
89     wxTextPos GetLastPosition() const;
90     void SetSelection( long from, long to );
91     void SelectAll();
92     void SetEditable( bool editable );
93 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
94     bool AutoComplete( const wxArrayString& choices );
95     bool AutoCompleteFileNames();
96 #endif
97 };
98
99 %{
100
101 void
102 wxTextCtrlBase::GetSelection()
103   PREINIT:
104     long from;
105     long to;
106   PPCODE:
107     THIS->GetSelection( &from, &to );
108     EXTEND( SP, 2 );
109     PUSHs( sv_2mortal( newSViv( from ) ) );
110     PUSHs( sv_2mortal( newSViv( to ) ) );
111
112 void
113 wxTextCtrlBase::PositionToXY( pos )
114     long pos
115   PREINIT:
116     long x;
117     long y;
118   PPCODE:
119     THIS->PositionToXY( pos, &x, &y );
120     EXTEND( SP, 2 );
121     PUSHs( sv_2mortal( newSViv( x ) ) );
122     PUSHs( sv_2mortal( newSViv( y ) ) );
123
124 void
125 wxTextCtrlBase::HitTest( pt )
126     wxPoint pt
127   PPCODE:
128     long col, row;
129     wxTextCtrlHitTestResult res = THIS->HitTest( pt, &col, &row );
130
131     EXTEND( SP, 3 );
132     PUSHs( sv_2mortal( newSViv( res ) ) );
133     PUSHs( sv_2mortal( newSViv( col ) ) );
134     PUSHs( sv_2mortal( newSViv( row ) ) );
135
136 %}
137
138 %name{Wx::TextCtrl} class wxTextCtrl
139 {
140 #if defined( __WXMAC__ ) && WXPERL_W_VERSION_GE( 2, 8, 0 )
141     void MacCheckSpelling( bool check );
142 #endif
143 };
144
145 %{
146 void
147 new( ... )
148   PPCODE:
149     BEGIN_OVERLOAD()
150         MATCH_VOIDM_REDISP( newDefault )
151         MATCH_ANY_REDISP( newFull )
152     END_OVERLOAD( "Wx::TextCtrl::new" )
153
154 wxTextCtrl*
155 newDefault( CLASS )
156     PlClassName CLASS
157   CODE:
158     RETVAL = new wxTextCtrl();
159     wxPli_create_evthandler( aTHX_ RETVAL, CLASS );
160   OUTPUT: RETVAL
161
162 wxTextCtrl*
163 newFull( CLASS, parent, id, value, pos = wxDefaultPosition, size = wxDefaultSize, style = 0 , validator = (wxValidator*)&wxDefaultValidator, name = wxTextCtrlNameStr )
164     PlClassName CLASS
165     wxWindow* parent
166     wxWindowID id
167     wxString value
168     wxPoint pos
169     wxSize size
170     long style
171     wxValidator* validator
172     wxString name
173   CODE:
174     RETVAL = new wxTextCtrl( parent, id, value, pos, size,
175                              style, *validator, name );
176     wxPli_create_evthandler( aTHX_ RETVAL, CLASS );
177   OUTPUT:
178     RETVAL
179
180 bool
181 wxTextCtrl::Create( parent, id, value, pos = wxDefaultPosition, size = wxDefaultSize, style = 0 , validator = (wxValidator*)&wxDefaultValidator, name = wxTextCtrlNameStr )
182     wxWindow* parent
183     wxWindowID id
184     wxString value
185     wxPoint pos
186     wxSize size
187     long style
188     wxValidator* validator
189     wxString name
190   C_ARGS: parent, id, value, pos, size, style, *validator, name
191
192 void
193 wxTextCtrl::GetStyle( position )
194     long position
195   PPCODE:
196     wxTextAttr attr;
197     bool retval = THIS->GetStyle( position, attr );
198     EXTEND( SP, 2 );
199     PUSHs( newSViv( retval ) );
200     PUSHs( retval ? wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
201                                            new wxTextAttr( attr ),
202                                            "Wx::TextAttr" ) :
203                     &PL_sv_undef );
204
205 ## to be consistent with RichTextCtrl
206
207 void
208 wxTextCtrl::GetTextAttrStyle( position )
209     long position
210   PPCODE:
211     wxTextAttr attr;
212     bool retval = THIS->GetStyle( position, attr );
213     EXTEND( SP, 2 );
214     PUSHs( newSViv( retval ) );
215     PUSHs( retval ? wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
216                                            new wxTextAttr( attr ),
217                                            "Wx::TextAttr" ) :
218                     &PL_sv_undef );
219
220 %}