1 #############################################################################
3 ## Purpose: XS for Wx::Bitmap and Wx::Mask
4 ## Author: Mattia Barbon
7 ## RCS-ID: $Id: Bitmap.xs 2069 2007-07-08 15:33:40Z mbarbon $
8 ## Copyright: (c) 2000-2002, 2005-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/bitmap.h>
15 MODULE=Wx PACKAGE=Wx::Mask
21 MATCH_REDISP( wxPliOvl_wbmp_wcol, newBitmapColour )
22 MATCH_REDISP( wxPliOvl_wbmp_n, newBitmapIndex )
23 MATCH_REDISP( wxPliOvl_wbmp, newBitmap )
24 END_OVERLOAD( Wx::Mask::new )
27 newBitmap( CLASS, bitmap )
31 RETVAL = new wxMask( *bitmap );
36 newBitmapColour( CLASS, bitmap, colour )
41 RETVAL = new wxMask( *bitmap, *colour );
46 newBitmapIndex( CLASS, bitmap, index )
51 RETVAL = new wxMask( *bitmap, index );
60 MODULE=Wx PACKAGE=Wx::Bitmap
65 bmp_spaceship( bmp1, bmp2, ... )
69 // this is not a proper spaceship method
70 // it just allows autogeneration of != and ==
71 // anyway, comparing bitmaps is just useless
73 if( SvROK( bmp1 ) && SvROK( bmp2 ) &&
74 sv_derived_from( bmp1, "Wx::Bitmap" ) &&
75 sv_derived_from( bmp2, "Wx::Bitmap" ) )
77 wxBitmap* bitmap1 = (wxBitmap*)_sv_2_object( bmp1, "Wx::Bitmap" );
78 wxBitmap* bitmap2 = (wxBitmap*)_sv_2_object( bmp2, "Wx::Bitmap" );
80 RETVAL = *bitmap1 == *bitmap2 ? 0 : 1;
92 MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_n_n, newEmpty, 2 )
93 MATCH_REDISP( wxPliOvl_s_n, newFile )
94 MATCH_REDISP( wxPliOvl_wico, newIcon )
95 MATCH_REDISP( wxPliOvl_wimg, newImage )
96 END_OVERLOAD( Wx::Bitmap::new )
99 newEmpty( CLASS, width, height, depth = -1 )
105 RETVAL = new wxBitmap( width, height, depth );
110 newFile( CLASS, name, type )
115 #if WXPERL_W_VERSION_GE( 2, 5, 0 )
116 RETVAL = new wxBitmap( name, wxBitmapType(type) );
118 RETVAL = new wxBitmap( name, type );
124 newIcon( CLASS, icon )
128 RETVAL = new wxBitmap( *icon );
133 newFromBits( CLASS, bits, width, height, depth = 1 )
140 char* buffer = SvPV_nolen( bits );
142 RETVAL = new wxBitmap( buffer, width, height, depth );
147 newFromXPM( CLASS, data )
152 size_t i, n = wxPli_av_2_charparray( aTHX_ data, &xpm_data );
154 RETVAL = new wxBitmap( xpm_data );
155 for( i = 0; i < n; ++i )
161 newImage( CLASS, image )
165 RETVAL = new wxBitmap( *image );
172 wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
178 wxPli_thread_sv_unregister( aTHX_ "Wx::Bitmap", THIS, ST(0) );
182 wxBitmap::ConvertToImage()
184 RETVAL = new wxImage( THIS->ConvertToImage() );
189 wxBitmap::CopyFromIcon( icon )
192 THIS->CopyFromIcon( *icon );
194 #if defined( __WXMOTIF__ ) || \
195 defined( __WXMSW__ ) || \
196 defined( __WXPERL_FORCE__ )
199 AddHandler( handler )
200 wxBitmapHandler* handler
202 wxBitmap::AddHandler( handler );
207 # wxBitmap::CleanUpHandlers();
211 #if defined( __WXMOTIF__ ) || defined( __WXPERL_FORCE__ )
214 FindHandlerName( name )
217 RETVAL = wxBitmap::FindHandler( name );
222 FindHandlerExtType( extension, type )
226 #if WXPERL_W_VERSION_GE( 2, 5, 1 ) && defined(__WXMOTIF__)
227 RETVAL = wxBitmap::FindHandler( extension, wxBitmapType(type) );
229 RETVAL = wxBitmap::FindHandler( extension, type );
235 FindHandlerType( type )
238 #if WXPERL_W_VERSION_GE( 2, 5, 1 ) && defined(__WXMOTIF__)
239 RETVAL = wxBitmap::FindHandler( wxBitmapType(type) );
241 RETVAL = wxBitmap::FindHandler( type );
251 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) \
252 || defined( __WXPERL_FORCE__ )
257 const wxList& list = wxBitmap::GetHandlers();
260 EXTEND( SP, list.GetCount() );
262 for( node = list.GetFirst(); node; node = node->GetNext() )
263 PUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(), node->GetData() ) );
268 wxBitmap::GetHeight()
271 wxBitmap::GetPalette()
273 RETVAL = new wxPalette( *THIS->GetPalette() );
284 wxBitmap::GetSubBitmap( rect )
287 RETVAL = new wxBitmap( THIS->GetSubBitmap( *rect ) );
291 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
294 InitStandardHandlers()
296 wxBitmap::InitStandardHandlers();
299 InsertHandler( handler )
300 wxBitmapHandler* handler
302 wxBitmap::InsertHandler( handler );
306 #if WXPERL_W_VERSION_GE( 2, 3, 1 )
309 wxBitmap::LoadFile( name, type )
316 wxBitmap::LoadFile( name, type )
325 #if WXPERL_W_VERSION_GE( 2, 8, 0 )
332 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
335 RemoveHandler( name )
338 RETVAL = wxBitmap::RemoveHandler( name );
344 wxBitmap::SaveFile( name, type, palette = 0 )
350 wxBitmap::SetDepth( depth )
354 wxBitmap::SetHeight( height )
358 wxBitmap::SetMask( mask )
361 THIS->SetMask( mask );
363 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
366 wxBitmap::SetPalette( palette )
369 THIS->SetPalette( *palette );
374 wxBitmap::SetWidth( width )