Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / XS / Bitmap.xs
1 #############################################################################
2 ## Name:        XS/Bitmap.xs
3 ## Purpose:     XS for Wx::Bitmap and Wx::Mask
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     29/10/2000
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 #############################################################################
12
13 #include <wx/bitmap.h>
14
15 MODULE=Wx PACKAGE=Wx::Mask
16
17 void
18 wxMask::new( ... )
19   PPCODE:
20     BEGIN_OVERLOAD()
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 )
25
26 wxMask*
27 newBitmap( CLASS, bitmap )
28     SV* CLASS
29     wxBitmap* bitmap
30   CODE:
31     RETVAL = new wxMask( *bitmap );
32   OUTPUT:
33     RETVAL
34
35 wxMask*
36 newBitmapColour( CLASS, bitmap, colour )
37     SV* CLASS
38     wxBitmap* bitmap
39     wxColour* colour
40   CODE:
41     RETVAL = new wxMask( *bitmap, *colour );
42   OUTPUT:
43     RETVAL
44
45 wxMask*
46 newBitmapIndex( CLASS, bitmap, index )
47     SV* CLASS
48     wxBitmap* bitmap
49     int index
50   CODE:
51     RETVAL = new wxMask( *bitmap, index );
52   OUTPUT:
53     RETVAL
54
55 void
56 wxMask::Destroy()
57   CODE:
58     delete THIS;
59
60 MODULE=Wx PACKAGE=Wx::Bitmap
61
62 #if 0
63
64 int
65 bmp_spaceship( bmp1, bmp2, ... )
66     SV* bmp1
67     SV* bmp2
68   CODE:
69     // this is not a proper spaceship method
70     // it just allows autogeneration of != and ==
71     // anyway, comparing bitmaps is just useless
72     RETVAL = -1;
73     if( SvROK( bmp1 ) && SvROK( bmp2 ) &&
74         sv_derived_from( bmp1, "Wx::Bitmap" ) &&
75         sv_derived_from( bmp2, "Wx::Bitmap" ) )
76     {
77         wxBitmap* bitmap1 = (wxBitmap*)_sv_2_object( bmp1, "Wx::Bitmap" );
78         wxBitmap* bitmap2 = (wxBitmap*)_sv_2_object( bmp2, "Wx::Bitmap" );
79
80         RETVAL = *bitmap1 == *bitmap2 ? 0 : 1;
81     } else
82       RETVAL = 1;
83   OUTPUT:
84     RETVAL
85
86 #endif
87
88 void
89 wxBitmap::new( ... )
90   PPCODE:
91     BEGIN_OVERLOAD()
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 )
97
98 wxBitmap*
99 newEmpty( CLASS, width, height, depth = -1 )
100     SV* CLASS
101     int width
102     int height
103     int depth
104   CODE:
105     RETVAL = new wxBitmap( width, height, depth );
106   OUTPUT:
107     RETVAL
108
109 wxBitmap*
110 newFile( CLASS, name, type )
111     SV* CLASS
112     wxString name
113     long type
114   CODE:
115 #if WXPERL_W_VERSION_GE( 2, 5, 0 )
116     RETVAL = new wxBitmap( name, wxBitmapType(type) );
117 #else
118     RETVAL = new wxBitmap( name, type );
119 #endif
120   OUTPUT:
121     RETVAL
122
123 wxBitmap*
124 newIcon( CLASS, icon )
125     SV* CLASS
126     wxIcon* icon
127   CODE:
128     RETVAL = new wxBitmap( *icon );
129   OUTPUT:
130     RETVAL
131
132 wxBitmap*
133 newFromBits( CLASS, bits, width, height, depth = 1 )
134     SV* CLASS
135     SV* bits
136     int width
137     int height
138     int depth
139   PREINIT:
140     char* buffer = SvPV_nolen( bits );
141   CODE:
142     RETVAL = new wxBitmap( buffer, width, height, depth );
143   OUTPUT:
144     RETVAL
145
146 wxBitmap*
147 newFromXPM( CLASS, data )
148     SV* CLASS
149     SV* data
150   PREINIT:
151     char** xpm_data;
152     size_t i, n = wxPli_av_2_charparray( aTHX_ data, &xpm_data );
153   CODE:
154     RETVAL = new wxBitmap( xpm_data );
155     for( i = 0; i < n; ++i )
156         free( xpm_data[i] );
157   OUTPUT:
158     RETVAL
159
160 wxBitmap*
161 newImage( CLASS, image )
162     SV* CLASS
163     wxImage* image
164   CODE:
165     RETVAL = new wxBitmap( *image );
166   OUTPUT:
167     RETVAL
168
169 static void
170 wxBitmap::CLONE()
171   CODE:
172     wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
173
174 ## // thread OK
175 void
176 wxBitmap::DESTROY()
177   CODE:
178     wxPli_thread_sv_unregister( aTHX_ "Wx::Bitmap", THIS, ST(0) );
179     delete THIS;
180
181 wxImage*
182 wxBitmap::ConvertToImage()
183   CODE:
184     RETVAL = new wxImage( THIS->ConvertToImage() );
185   OUTPUT:
186     RETVAL
187
188 void
189 wxBitmap::CopyFromIcon( icon )
190     wxIcon* icon
191   CODE:
192     THIS->CopyFromIcon( *icon );
193
194 #if defined( __WXMOTIF__ ) || \
195     defined( __WXMSW__ ) || \
196     defined( __WXPERL_FORCE__ )
197
198 void
199 AddHandler( handler )
200     wxBitmapHandler* handler
201   CODE:
202     wxBitmap::AddHandler( handler );
203
204 # void
205 # CleanUpHandlers()
206 #   CODE:
207 #     wxBitmap::CleanUpHandlers();
208
209 #endif
210
211 #if defined( __WXMOTIF__ ) || defined( __WXPERL_FORCE__ )
212
213 wxBitmapHandler*
214 FindHandlerName( name )
215     wxString name
216   CODE:
217     RETVAL = wxBitmap::FindHandler( name );
218   OUTPUT:
219     RETVAL
220
221 wxBitmapHandler*
222 FindHandlerExtType( extension, type )
223     wxString extension
224     long type
225   CODE:
226 #if WXPERL_W_VERSION_GE( 2, 5, 1 ) && defined(__WXMOTIF__)
227     RETVAL = wxBitmap::FindHandler( extension, wxBitmapType(type) );
228 #else
229     RETVAL = wxBitmap::FindHandler( extension, type );
230 #endif
231   OUTPUT:
232     RETVAL
233
234 wxBitmapHandler*
235 FindHandlerType( type )
236     long type
237   CODE:
238 #if WXPERL_W_VERSION_GE( 2, 5, 1 ) && defined(__WXMOTIF__)
239     RETVAL = wxBitmap::FindHandler( wxBitmapType(type) );
240 #else
241     RETVAL = wxBitmap::FindHandler( type );
242 #endif
243   OUTPUT:
244     RETVAL
245
246 #endif
247
248 int
249 wxBitmap::GetDepth()
250
251 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) \
252     || defined( __WXPERL_FORCE__ )
253
254 void
255 GetHandlers()
256   PPCODE:
257     const wxList& list = wxBitmap::GetHandlers();
258     wxNode* node;
259     
260     EXTEND( SP, list.GetCount() );
261
262     for( node = list.GetFirst(); node; node = node->GetNext() )
263       PUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(), node->GetData() ) );
264
265 #endif
266
267 int
268 wxBitmap::GetHeight()
269
270 wxPalette*
271 wxBitmap::GetPalette()
272   CODE:
273     RETVAL = new wxPalette( *THIS->GetPalette() );
274   OUTPUT:
275     RETVAL
276
277 wxMask*
278 wxBitmap::GetMask()
279
280 int
281 wxBitmap::GetWidth()
282
283 wxBitmap*
284 wxBitmap::GetSubBitmap( rect )
285     wxRect* rect
286   CODE:
287     RETVAL = new wxBitmap( THIS->GetSubBitmap( *rect ) );
288   OUTPUT:
289     RETVAL
290
291 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
292
293 void
294 InitStandardHandlers()
295   CODE:
296     wxBitmap::InitStandardHandlers();
297
298 void
299 InsertHandler( handler )
300     wxBitmapHandler* handler
301   CODE:
302     wxBitmap::InsertHandler( handler );
303
304 #endif
305
306 #if WXPERL_W_VERSION_GE( 2, 3, 1 )
307
308 bool
309 wxBitmap::LoadFile( name, type )
310     wxString name
311     wxBitmapType type
312
313 #else
314
315 bool
316 wxBitmap::LoadFile( name, type )
317     wxString name
318     long type
319
320 #endif
321
322 bool
323 wxBitmap::Ok()
324
325 #if WXPERL_W_VERSION_GE( 2, 8, 0 )
326
327 bool
328 wxBitmap::IsOk()
329
330 #endif
331
332 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
333
334 bool
335 RemoveHandler( name )
336     wxString name
337   CODE:
338     RETVAL = wxBitmap::RemoveHandler( name );
339   OUTPUT: RETVAL
340
341 #endif
342
343 bool
344 wxBitmap::SaveFile( name, type, palette = 0 )
345     wxString name
346     wxBitmapType type
347     wxPalette* palette
348
349 void
350 wxBitmap::SetDepth( depth )
351     int depth
352
353 void
354 wxBitmap::SetHeight( height )
355     int height
356
357 void
358 wxBitmap::SetMask( mask )
359     wxMask* mask
360   CODE:
361     THIS->SetMask( mask );
362
363 #if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
364
365 void
366 wxBitmap::SetPalette( palette )
367     wxPalette* palette
368   CODE:
369     THIS->SetPalette( *palette );
370
371 #endif
372
373 void
374 wxBitmap::SetWidth( width )
375     int width