File: Bitmap.xs

package info (click to toggle)
libwx-perl 1%3A0.9909-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,912 kB
  • sloc: cpp: 9,728; perl: 8,182; ansic: 626; makefile: 41
file content (375 lines) | stat: -rw-r--r-- 7,232 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
#############################################################################
## Name:        XS/Bitmap.xs
## Purpose:     XS for Wx::Bitmap and Wx::Mask
## Author:      Mattia Barbon
## Modified by:
## Created:     29/10/2000
## RCS-ID:      $Id: Bitmap.xs 2069 2007-07-08 15:33:40Z mbarbon $
## Copyright:   (c) 2000-2002, 2005-2007 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

#include <wx/bitmap.h>

MODULE=Wx PACKAGE=Wx::Mask

void
wxMask::new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_REDISP( wxPliOvl_wbmp_wcol, newBitmapColour )
        MATCH_REDISP( wxPliOvl_wbmp_n, newBitmapIndex )
        MATCH_REDISP( wxPliOvl_wbmp, newBitmap )
    END_OVERLOAD( Wx::Mask::new )

wxMask*
newBitmap( CLASS, bitmap )
    SV* CLASS
    wxBitmap* bitmap
  CODE:
    RETVAL = new wxMask( *bitmap );
  OUTPUT:
    RETVAL

wxMask*
newBitmapColour( CLASS, bitmap, colour )
    SV* CLASS
    wxBitmap* bitmap
    wxColour* colour
  CODE:
    RETVAL = new wxMask( *bitmap, *colour );
  OUTPUT:
    RETVAL

wxMask*
newBitmapIndex( CLASS, bitmap, index )
    SV* CLASS
    wxBitmap* bitmap
    int index
  CODE:
    RETVAL = new wxMask( *bitmap, index );
  OUTPUT:
    RETVAL

void
wxMask::Destroy()
  CODE:
    delete THIS;

MODULE=Wx PACKAGE=Wx::Bitmap

#if 0

int
bmp_spaceship( bmp1, bmp2, ... )
    SV* bmp1
    SV* bmp2
  CODE:
    // this is not a proper spaceship method
    // it just allows autogeneration of != and ==
    // anyway, comparing bitmaps is just useless
    RETVAL = -1;
    if( SvROK( bmp1 ) && SvROK( bmp2 ) &&
        sv_derived_from( bmp1, "Wx::Bitmap" ) &&
        sv_derived_from( bmp2, "Wx::Bitmap" ) )
    {
        wxBitmap* bitmap1 = (wxBitmap*)_sv_2_object( bmp1, "Wx::Bitmap" );
        wxBitmap* bitmap2 = (wxBitmap*)_sv_2_object( bmp2, "Wx::Bitmap" );

        RETVAL = *bitmap1 == *bitmap2 ? 0 : 1;
    } else
      RETVAL = 1;
  OUTPUT:
    RETVAL

#endif

void
wxBitmap::new( ... )
  PPCODE:
    BEGIN_OVERLOAD()
        MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_n_n_n, newEmpty, 2 )
        MATCH_REDISP( wxPliOvl_s_n, newFile )
        MATCH_REDISP( wxPliOvl_wico, newIcon )
        MATCH_REDISP( wxPliOvl_wimg, newImage )
    END_OVERLOAD( Wx::Bitmap::new )

wxBitmap*
newEmpty( CLASS, width, height, depth = -1 )
    SV* CLASS
    int width
    int height
    int depth
  CODE:
    RETVAL = new wxBitmap( width, height, depth );
  OUTPUT:
    RETVAL

wxBitmap*
newFile( CLASS, name, type )
    SV* CLASS
    wxString name
    long type
  CODE:
#if WXPERL_W_VERSION_GE( 2, 5, 0 )
    RETVAL = new wxBitmap( name, wxBitmapType(type) );
#else
    RETVAL = new wxBitmap( name, type );
#endif
  OUTPUT:
    RETVAL

wxBitmap*
newIcon( CLASS, icon )
    SV* CLASS
    wxIcon* icon
  CODE:
    RETVAL = new wxBitmap( *icon );
  OUTPUT:
    RETVAL

wxBitmap*
newFromBits( CLASS, bits, width, height, depth = 1 )
    SV* CLASS
    SV* bits
    int width
    int height
    int depth
  PREINIT:
    char* buffer = SvPV_nolen( bits );
  CODE:
    RETVAL = new wxBitmap( buffer, width, height, depth );
  OUTPUT:
    RETVAL

wxBitmap*
newFromXPM( CLASS, data )
    SV* CLASS
    SV* data
  PREINIT:
    char** xpm_data;
    size_t i, n = wxPli_av_2_charparray( aTHX_ data, &xpm_data );
  CODE:
    RETVAL = new wxBitmap( xpm_data );
    for( i = 0; i < n; ++i )
        free( xpm_data[i] );
  OUTPUT:
    RETVAL

wxBitmap*
newImage( CLASS, image )
    SV* CLASS
    wxImage* image
  CODE:
    RETVAL = new wxBitmap( *image );
  OUTPUT:
    RETVAL

static void
wxBitmap::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );

## // thread OK
void
wxBitmap::DESTROY()
  CODE:
    wxPli_thread_sv_unregister( aTHX_ "Wx::Bitmap", THIS, ST(0) );
    delete THIS;

wxImage*
wxBitmap::ConvertToImage()
  CODE:
    RETVAL = new wxImage( THIS->ConvertToImage() );
  OUTPUT:
    RETVAL

void
wxBitmap::CopyFromIcon( icon )
    wxIcon* icon
  CODE:
    THIS->CopyFromIcon( *icon );

#if defined( __WXMOTIF__ ) || \
    defined( __WXMSW__ ) || \
    defined( __WXPERL_FORCE__ )

void
AddHandler( handler )
    wxBitmapHandler* handler
  CODE:
    wxBitmap::AddHandler( handler );

# void
# CleanUpHandlers()
#   CODE:
#     wxBitmap::CleanUpHandlers();

#endif

#if defined( __WXMOTIF__ ) || defined( __WXPERL_FORCE__ )

wxBitmapHandler*
FindHandlerName( name )
    wxString name
  CODE:
    RETVAL = wxBitmap::FindHandler( name );
  OUTPUT:
    RETVAL

wxBitmapHandler*
FindHandlerExtType( extension, type )
    wxString extension
    long type
  CODE:
#if WXPERL_W_VERSION_GE( 2, 5, 1 ) && defined(__WXMOTIF__)
    RETVAL = wxBitmap::FindHandler( extension, wxBitmapType(type) );
#else
    RETVAL = wxBitmap::FindHandler( extension, type );
#endif
  OUTPUT:
    RETVAL

wxBitmapHandler*
FindHandlerType( type )
    long type
  CODE:
#if WXPERL_W_VERSION_GE( 2, 5, 1 ) && defined(__WXMOTIF__)
    RETVAL = wxBitmap::FindHandler( wxBitmapType(type) );
#else
    RETVAL = wxBitmap::FindHandler( type );
#endif
  OUTPUT:
    RETVAL

#endif

int
wxBitmap::GetDepth()

#if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) \
    || defined( __WXPERL_FORCE__ )

void
GetHandlers()
  PPCODE:
    const wxList& list = wxBitmap::GetHandlers();
    wxNode* node;
    
    EXTEND( SP, list.GetCount() );

    for( node = list.GetFirst(); node; node = node->GetNext() )
      PUSHs( wxPli_object_2_sv( aTHX_ sv_newmortal(), node->GetData() ) );

#endif

int
wxBitmap::GetHeight()

wxPalette*
wxBitmap::GetPalette()
  CODE:
    RETVAL = new wxPalette( *THIS->GetPalette() );
  OUTPUT:
    RETVAL

wxMask*
wxBitmap::GetMask()

int
wxBitmap::GetWidth()

wxBitmap*
wxBitmap::GetSubBitmap( rect )
    wxRect* rect
  CODE:
    RETVAL = new wxBitmap( THIS->GetSubBitmap( *rect ) );
  OUTPUT:
    RETVAL

#if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )

void
InitStandardHandlers()
  CODE:
    wxBitmap::InitStandardHandlers();

void
InsertHandler( handler )
    wxBitmapHandler* handler
  CODE:
    wxBitmap::InsertHandler( handler );

#endif

#if WXPERL_W_VERSION_GE( 2, 3, 1 )

bool
wxBitmap::LoadFile( name, type )
    wxString name
    wxBitmapType type

#else

bool
wxBitmap::LoadFile( name, type )
    wxString name
    long type

#endif

bool
wxBitmap::Ok()

#if WXPERL_W_VERSION_GE( 2, 8, 0 )

bool
wxBitmap::IsOk()

#endif

#if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )

bool
RemoveHandler( name )
    wxString name
  CODE:
    RETVAL = wxBitmap::RemoveHandler( name );
  OUTPUT: RETVAL

#endif

bool
wxBitmap::SaveFile( name, type, palette = 0 )
    wxString name
    wxBitmapType type
    wxPalette* palette

void
wxBitmap::SetDepth( depth )
    int depth

void
wxBitmap::SetHeight( height )
    int height

void
wxBitmap::SetMask( mask )
    wxMask* mask
  CODE:
    THIS->SetMask( mask );

#if defined( __WXMOTIF__ ) || defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )

void
wxBitmap::SetPalette( palette )
    wxPalette* palette
  CODE:
    THIS->SetPalette( *palette );

#endif

void
wxBitmap::SetWidth( width )
    int width