Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / XS / Icon.xs
1 #############################################################################
2 ## Name:        XS/Icon.xs
3 ## Purpose:     XS for Wx::Icon
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     29/10/2000
7 ## RCS-ID:      $Id: Icon.xs 2517 2008-11-30 20:14:22Z mbarbon $
8 ## Copyright:   (c) 2000-2004, 2006-2008 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/icon.h>
14
15 MODULE=Wx PACKAGE=Wx
16
17 #if !defined( __WXMSW__ )
18 #include "wxpl.xpm"
19 #endif
20
21 wxIcon*
22 GetWxPerlIcon( get_small = false )
23     bool get_small
24   CODE:
25 #if defined( __WXMSW__ )
26     int sz = get_small ? 16 : 32;
27     RETVAL = new wxIcon( wxT("wxplicon"), wxBITMAP_TYPE_ICO_RESOURCE, -1, -1 );
28     if( !RETVAL->Ok() )
29         croak( "Unable to load icon" );
30 #else
31     char** image = (char**)( get_small ? wxpl16_xpm : wxpl32_xpm );
32     RETVAL = new wxIcon( image );
33 #endif
34   OUTPUT:
35     RETVAL
36
37 MODULE=Wx PACKAGE=Wx::Icon
38
39 ## DECLARE_OVERLOAD( wilo, Wx::IconLocation )
40
41 void
42 wxIcon::new( ... )
43   PPCODE:
44     BEGIN_OVERLOAD()
45         MATCH_VOIDM_REDISP( newNull )
46         MATCH_REDISP( wxPliOvl_wilo, newLocation )
47         MATCH_REDISP_COUNT_ALLOWMORE( wxPliOvl_s_n_n_n, newFile, 2 )
48     END_OVERLOAD( Wx::Icon::new )
49
50 wxIcon*
51 newNull( CLASS )
52     SV* CLASS
53   CODE:
54     RETVAL = new wxIcon();
55   OUTPUT:
56     RETVAL
57
58 wxIcon*
59 newFile( CLASS, name, type, desW = -1, desH = -1 )
60     SV* CLASS
61     wxString name
62     long type
63     int desW
64     int desH
65   CODE:
66 #if defined( __WXMOTIF__ ) || defined( __WXX11__ ) || defined( __WXGTK__ ) \
67     || WXPERL_W_VERSION_GE( 2, 9, 0 )
68     RETVAL = new wxIcon( name, wxBitmapType(type), desW, desH );
69 #else
70     RETVAL = new wxIcon( name, type, desW, desH );
71 #endif
72   OUTPUT:
73     RETVAL
74
75 #if defined( __WXGTK__ ) || defined( __WXPERL_FORCE__ )
76
77 ##wxIcon*
78 ##newFromBits( bits, width, height, depth = 1 )
79 ##    SV* bits
80 ##    int width
81 ##    int height
82 ##    int depth
83 ##  PREINIT:
84 ##    void* buffer = SvPV_nolen( bits );
85 ##  CODE:
86 ##    RETVAL = new wxIcon( buffer, width, height, depth );
87 ##  OUTPUT:
88 ##    RETVAL
89
90 #endif
91
92 wxIcon*
93 newFromXPM( CLASS, data )
94     SV* CLASS
95     SV* data
96   PREINIT:
97     char** xpm_data;
98     size_t i, n = wxPli_av_2_charparray( aTHX_ data, &xpm_data );
99   CODE:
100     RETVAL = new wxIcon( xpm_data );
101     for( i = 0; i < n; ++i )
102         free( xpm_data[i] );
103   OUTPUT:
104     RETVAL
105
106 #if WXPERL_W_VERSION_GE( 2, 5, 2 )
107
108 wxIcon*
109 newLocation( CLASS, location )
110     SV* CLASS
111     wxIconLocation* location
112   CODE:
113     RETVAL = new wxIcon( *location );
114   OUTPUT: RETVAL
115
116 #endif
117
118 static void
119 wxIcon::CLONE()
120   CODE:
121     wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
122
123 ## // thread OK
124 void
125 wxIcon::DESTROY()
126   CODE:
127     wxPli_thread_sv_unregister( aTHX_ "Wx::Icon", THIS, ST(0) );
128     delete THIS;
129
130 bool
131 wxIcon::LoadFile( name, type )
132     wxString name
133     long type
134   CODE:
135 #if defined( __WXMOTIF__ )
136 #if WXPERL_W_VERSION_GE( 2, 5, 1 )
137         RETVAL = THIS->LoadFile( name, wxBitmapType(type), -1, -1 );
138 #else
139         RETVAL = THIS->LoadFile( name, type, -1, -1 );
140 #endif
141 #else
142 #if defined( __WXX11__ ) || defined( __WXMAC__ ) || defined( __WXGTK__ ) \
143     || ( defined(__WXMSW__) && WXPERL_W_VERSION_GE( 2, 9, 0 ) )
144     RETVAL = THIS->LoadFile( name, wxBitmapType(type) );
145 #else
146     RETVAL = THIS->LoadFile( name, type );
147 #endif
148 #endif
149   OUTPUT:
150     RETVAL
151
152 bool
153 wxIcon::Ok()
154
155 #if WXPERL_W_VERSION_GE( 2, 8, 0 )
156
157 bool
158 wxIcon::IsOk()
159
160 #endif
161
162 void
163 wxIcon::CopyFromBitmap( bitmap )
164     wxBitmap* bitmap
165   C_ARGS: *bitmap
166
167 #if defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
168
169 int
170 wxIcon::GetDepth()
171
172 int
173 wxIcon::GetHeight()
174
175 int
176 wxIcon::GetWidth()
177
178 void
179 wxIcon::SetDepth( depth )
180     int depth
181
182 void
183 wxIcon::SetHeight( height )
184     int height
185
186 void
187 wxIcon::SetWidth( width )
188     int width
189
190 #endif