1 #############################################################################
2 ## Name: ext/dnd/XS/DataObject.xs
3 ## Purpose: XS for Wx::*DataObject and Wx::DataFormat
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: DataObject.xs 2055 2007-06-18 22:05:48Z mbarbon $
8 ## Copyright: (c) 2001-2004, 2006-2007 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 #############################################################################
13 #include <wx/dataobj.h>
14 #include "cpp/dataobject.h"
16 MODULE=Wx PACKAGE=Wx::DataFormat
21 newNative( dummy, format = wxDF_INVALID )
25 RETVAL = new wxDataFormat( format );
31 newNative( dummy, format = wxDF_INVALID )
35 RETVAL = new wxDataFormat( format );
40 #if WXPERL_W_VERSION_GE( 2, 9, 0 )
47 RETVAL = new wxDataFormat( id );
57 RETVAL = new wxDataFormat( id );
65 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
69 wxDataFormat::DESTROY()
71 wxPli_thread_sv_unregister( aTHX_ "Wx::DataFormat", THIS, ST(0) );
78 wxDataFormat::SetId( id )
81 #if defined( __WXMSW__ )
84 wxDataFormat::GetType()
87 wxDataFormat::SetType( type )
93 wxDataFormat::GetType()
98 wxDataFormat::SetType( type )
105 MODULE=Wx PACKAGE=Wx::DataObject
108 wxDataObject::CLONE()
110 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
117 wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ), THIS, ST(0) );
118 if( THIS && wxPli_object_is_deleteable( aTHX_ ST(0) ) )
124 wxDataObject::Destroy()
126 wxPli_thread_sv_unregister( aTHX_ wxPli_get_class( aTHX_ ST(0) ), THIS, ST(0) );
130 wxDataObject::GetAllFormats( dir = wxDataObjectBase::Get )
133 size_t formats = THIS->GetFormatCount( dir );
134 size_t i, wanted = formats;
135 wxDataFormat* formats_d = new wxDataFormat[ formats ];
137 THIS->GetAllFormats( formats_d, dir );
138 if( GIMME_V == G_SCALAR )
140 EXTEND( SP, (IV)wanted );
141 for( i = 0; i < wanted; ++i )
143 PUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
144 new wxDataFormat( formats_d[i] ), "Wx::DataFormat" ) );
149 wxDataObject::GetDataHere( format, buf )
153 size_t size = THIS->GetDataSize( *format );
154 void* buffer = SvGROW( buf, size + 1 );
156 SvCUR_set( buf, size );
157 RETVAL = THIS->GetDataHere( *format, buffer );
161 wxDataObject::GetDataSize( format )
164 RETVAL = THIS->GetDataSize( *format );
168 wxDataObject::GetFormatCount( dir = wxDataObjectBase::Get )
172 wxDataObject::GetPreferredFormat( dir = wxDataObjectBase::Get )
175 RETVAL = new wxDataFormat( THIS->GetPreferredFormat( dir ) );
179 wxDataObject::IsSupported( format, dir = wxDataObjectBase::Get )
183 RETVAL = THIS->IsSupported( *format, dir );
187 wxDataObject::SetData( format, buf )
194 data = SvPV( buf, len );
195 RETVAL = THIS->SetData( *format, len, data );
198 MODULE=Wx PACKAGE=Wx::DataObjectSimple
201 wxDataObjectSimple::new( format = (wxDataFormat*)&wxFormatInvalid )
204 RETVAL = new wxDataObjectSimple( *format );
208 wxDataObjectSimple::GetFormat()
210 RETVAL = new wxDataFormat( THIS->GetFormat() );
214 wxDataObjectSimple::SetFormat( format )
217 THIS->SetFormat( *format );
219 MODULE=Wx PACKAGE=Wx::PlDataObjectSimple
222 wxPlDataObjectSimple::new( format = (wxDataFormat*)&wxFormatInvalid )
225 wxPlDataObjectSimple* THIS = new wxPlDataObjectSimple( CLASS, *format );
226 RETVAL = newRV_noinc( SvRV( THIS->m_callback.GetSelf() ) );
227 wxPli_thread_sv_register( aTHX_ "Wx::PlDataObjectSimple", THIS, RETVAL );
232 wxPlDataObjectSimple::DESTROY()
234 wxPli_thread_sv_unregister( aTHX_ "Wx::PlDataObjectSimple", THIS, ST(0) );
235 if( THIS && wxPli_object_is_deleteable( aTHX_ ST(0) ) )
237 SV* self = THIS->m_callback.GetSelf();
243 MODULE=Wx PACKAGE=Wx::DataObjectComposite
245 wxDataObjectComposite*
246 wxDataObjectComposite::new()
249 wxDataObjectComposite::Add( dataObject, preferred = false )
250 wxDataObjectSimple* dataObject
253 // at this point the data object is owned!
254 wxPli_object_set_deleteable( aTHX_ ST(1), false );
255 SvREFCNT_inc( SvRV( ST(1) ) ); // at this point the scalar must not go away
256 THIS->Add( dataObject, preferred );
258 #if WXPERL_W_VERSION_GE( 2, 7, 0 )
261 wxDataObjectComposite::GetReceivedFormat()
263 RETVAL = new wxDataFormat( THIS->GetReceivedFormat() );
268 MODULE=Wx PACKAGE=Wx::TextDataObject
271 wxTextDataObject::new( text = wxEmptyString )
275 wxTextDataObject::GetTextLength()
278 wxTextDataObject::GetText()
281 wxTextDataObject::SetText( text )
284 MODULE=Wx PACKAGE=Wx::BitmapDataObject
286 #if WXPERL_W_VERSION_GE( 2, 5, 1 ) || !defined(__WXMOTIF__)
289 wxBitmapDataObject::new( bitmap = (wxBitmap*)&wxNullBitmap )
292 RETVAL = new wxBitmapDataObject( *bitmap );
296 wxBitmapDataObject::GetBitmap()
298 RETVAL = new wxBitmap( THIS->GetBitmap() );
302 wxBitmapDataObject::SetBitmap( bitmap )
305 THIS->SetBitmap( *bitmap );
309 MODULE=Wx PACKAGE=Wx::FileDataObject
311 #if !defined(__WXMOTIF__)
314 wxFileDataObject::new()
317 wxFileDataObject::AddFile( file )
321 wxFileDataObject::GetFilenames()
325 const wxArrayString& filenames = THIS->GetFilenames();
326 max = filenames.GetCount();
328 for( i = 0; i < max; ++i ) {
330 SV* tmp = sv_2mortal( newSVpv( filenames[i].mb_str(wxConvUTF8), 0 ) );
334 PUSHs( sv_2mortal( newSVpv( CHAR_P filenames[i].c_str(), 0 ) ) );
338 MODULE=Wx PACKAGE=Wx::URLDataObject
341 wxURLDataObject::new()
344 wxURLDataObject::GetURL()
347 wxURLDataObject::SetURL( url )