Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / XS / Pen.xs
1 #############################################################################
2 ## Name:        XS/Pen.xs
3 ## Purpose:     XS for Wx::Pen
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     21/11/2000
7 ## RCS-ID:      $Id: Pen.xs 2340 2008-03-25 22:25:07Z mbarbon $
8 ## Copyright:   (c) 2000-2003, 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/colour.h>
14 #include <wx/pen.h>
15
16 MODULE=Wx PACKAGE=Wx::Pen
17
18 void
19 wxPen::new( ... )
20   PPCODE:
21     BEGIN_OVERLOAD()
22         MATCH_REDISP( wxPliOvl_wcol_n_n, newColour )
23         MATCH_REDISP( wxPliOvl_wbmp_n, newBitmap )
24         MATCH_REDISP( wxPliOvl_s_n_n, newString )
25     END_OVERLOAD( Wx::Pen::new )
26
27 wxPen*
28 newColour( CLASS, colour, width, style )
29     SV* CLASS
30     wxColour* colour
31     int width
32     int style
33   CODE:
34     RETVAL = new wxPen( *colour, width, style );
35   OUTPUT:
36     RETVAL
37
38 wxPen*
39 newString( CLASS, name, width, style )
40     SV* CLASS
41     wxString name
42     int width
43     int style
44   CODE:
45     RETVAL = new wxPen( name, width, style );
46   OUTPUT:
47     RETVAL
48
49 #if defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
50
51 wxPen*
52 newBitmap( CLASS, stipple, width )
53     SV* CLASS
54     wxBitmap* stipple
55     int width
56   CODE:
57     RETVAL = new wxPen( *stipple, width );
58
59 #endif
60
61 static void
62 wxPen::CLONE()
63   CODE:
64     wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
65
66 ## // thread OK
67 void
68 wxPen::DESTROY()
69   CODE:
70     wxPli_thread_sv_unregister( aTHX_ "Wx::Pen", THIS, ST(0) );
71     delete THIS;
72
73 wxPenCap
74 wxPen::GetCap()
75
76 wxColour*
77 wxPen::GetColour()
78   CODE:
79     RETVAL = new wxColour( THIS->GetColour() );
80   OUTPUT:
81     RETVAL
82
83 void
84 wxPen::GetDashes()
85   PREINIT:
86     int i, n;
87     wxDash* array;
88   PPCODE:
89     n = THIS->GetDashes( &array );
90     EXTEND( SP, n );
91     for( i = 0; i < n; ++i )
92     {
93       PUSHs( sv_2mortal( newSViv( array[i] ) ) );
94     }
95
96 wxPenJoin
97 wxPen::GetJoin()
98
99 #if defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
100
101 wxBitmap*
102 wxPen::GetStipple()
103   CODE:
104     RETVAL = new wxBitmap( *THIS->GetStipple() );
105   OUTPUT:
106     RETVAL
107
108 #endif
109
110 wxPenStyle
111 wxPen::GetStyle()
112
113 int
114 wxPen::GetWidth()
115
116 bool
117 wxPen::Ok()
118
119 #if WXPERL_W_VERSION_GE( 2, 8, 0 )
120
121 bool
122 wxPen::IsOk()
123
124 #endif
125
126 void
127 wxPen::SetCap( capStyle )
128     wxPenCap capStyle
129
130 void
131 wxPen::SetColour( ... )
132   PPCODE:
133      BEGIN_OVERLOAD()
134         MATCH_REDISP( wxPliOvl_wcol, SetColourColour )
135         MATCH_REDISP( wxPliOvl_n_n_n, SetColourRGB )
136         MATCH_REDISP( wxPliOvl_s, SetColourName )
137     END_OVERLOAD( Wx::Pen::SetColour )
138
139 void
140 wxPen::SetColourColour( colour )
141     wxColour* colour
142   CODE:
143     THIS->SetColour( *colour );
144
145 void
146 wxPen::SetColourName( name )
147     wxString name
148   CODE:
149     THIS->SetColour( name );
150
151 void
152 wxPen::SetColourRGB( r, g, b )
153     int r
154     int g
155     int b
156   CODE:
157     THIS->SetColour( r, g, b );
158
159 void
160 wxPen::SetDashes( ds )
161     SV* ds
162   PREINIT:
163     int n = 0;
164     wxDash* dashes = 0;
165     wxDash* olddashes;
166   CODE:
167     THIS->GetDashes( &olddashes );
168     if( SvOK( ds ) )
169     {
170       AV* av;
171       SV* t;
172       int i;
173
174       if( !SvROK( ds ) || 
175           ( SvTYPE( (SV*) ( av = (AV*) SvRV( ds ) ) ) != SVt_PVAV ) )
176       {
177           croak( "the value is not an array reference" );
178           XSRETURN_UNDEF;
179       }
180     
181       n = av_len( av ) + 1;
182       dashes = new wxDash[ n ];
183
184       for( i = 0; i < n; ++i )
185       {
186         t = *av_fetch( av, i, 0 );
187         dashes[i] = SvIV( t );
188       }
189     }
190     THIS->SetDashes( n, dashes );
191     delete[] olddashes;
192
193 void
194 wxPen::SetJoin( join_style )
195     wxPenJoin join_style
196
197 #if defined( __WXMSW__ ) || defined( __WXPERL_FORCE__ )
198
199 void
200 wxPen::SetStipple( stipple )
201     wxBitmap* stipple
202   CODE:
203     THIS->SetStipple( *stipple );
204
205 #endif
206
207 void
208 wxPen::SetStyle( style )
209     wxPenStyle style
210
211 void
212 wxPen::SetWidth( width )
213     int width