Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / XS / Accelerators.xs
1 #############################################################################
2 ## Name:        XS/Accelerators.xs
3 ## Purpose:     XS for Wx::AcceleratorTable, Wx::AcceleratorEntry
4 ## Author:      Mattia Barbon
5 ## Modified by:
6 ## Created:     13/02/2001
7 ## RCS-ID:      $Id: Accelerators.xs 2057 2007-06-18 23:03:00Z mbarbon $
8 ## Copyright:   (c) 2001-2002, 2004, 2006-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/accel.h>
14
15 MODULE=Wx PACKAGE=Wx::AcceleratorEntry
16
17 wxAcceleratorEntry*
18 wxAcceleratorEntry::new( flags, code, cmd )
19     int flags
20     wxKeyCode code
21     int cmd
22
23 #if WXPERL_W_VERSION_GE( 2, 7, 1 )
24
25 wxAcceleratorEntry*
26 Create( str )
27     wxString str;
28   CODE:
29     RETVAL = wxAcceleratorEntry::Create( str );
30   OUTPUT: RETVAL
31
32 #endif
33
34 static void
35 wxAcceleratorEntry::CLONE()
36   CODE:
37     wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
38
39 ## // thread OK
40 void
41 wxAcceleratorEntry::DESTROY()
42   CODE:
43     wxPli_thread_sv_unregister( aTHX_ "Wx::AcceleratorEntry", THIS, ST(0) );
44     delete THIS;
45
46 int
47 wxAcceleratorEntry::GetCommand()
48
49 int
50 wxAcceleratorEntry::GetFlags()
51
52 ## wxKeyCode
53 int
54 wxAcceleratorEntry::GetKeyCode()
55
56 void
57 wxAcceleratorEntry::Set( flags, code, cmd )
58     int flags
59     wxKeyCode code
60     int cmd
61
62 MODULE=Wx PACKAGE=Wx::AcceleratorTable
63
64 wxAcceleratorTable*
65 wxAcceleratorTable::new( ... )
66   CODE:
67     if( items == 1 )
68     {
69         RETVAL = new wxAcceleratorTable;
70     }
71     else
72     {
73         int num = items - 1;
74         wxAcceleratorEntry* entries = new wxAcceleratorEntry[ num ];
75
76         for( int i = 0; i < num; ++i )
77         {
78             SV* rv = ST( i + 1 );
79
80             if( SvROK( rv ) )
81             {
82                 if( sv_derived_from( rv, CHAR_P "Wx::AcceleratorEntry" ) )
83                 {
84                     entries[i] = *(wxAcceleratorEntry*)
85                         wxPli_sv_2_object( aTHX_ rv,
86                                            "Wx::AcceleratorEntry" );
87                 }
88                 else if( SvTYPE( SvRV( rv ) ) == SVt_PVAV )
89                 {
90                     AV* av = (AV*) SvRV( rv );
91                     I32 len = av_len( av ) + 1;
92
93                     if( len != 3 )
94                     {
95                         delete[] entries;
96                         croak( "the %d-th value does not have three"
97                                " elements", i + 1 );
98                     }
99
100                     entries[i].Set( SvIV( *av_fetch( av, 0, 0 ) ),
101                                     wxPli_sv_2_keycode( aTHX_
102                                             *av_fetch( av, 1, 0 ) ),
103                                     SvIV( *av_fetch( av, 2, 0 ) ) );
104                 }
105                 else
106                 {
107                     delete[] entries;
108                     croak( "the %d-th value is not an object"
109                            " or array reference", i + 1 );
110                 }
111             }
112             else
113             {
114                 delete[] entries;
115                 croak( "the %d-th value is not an object"
116                        " or array reference", i + 1 );
117             }
118         }
119
120         RETVAL = new wxAcceleratorTable( num, entries );
121         delete[] entries;
122     }
123   OUTPUT:
124     RETVAL
125
126 static void
127 wxAcceleratorTable::CLONE()
128   CODE:
129     wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
130
131 ## // thread OK
132 void
133 wxAcceleratorTable::DESTROY()
134   CODE:
135     wxPli_thread_sv_unregister( aTHX_ "Wx::AcceleratorTable", THIS, ST(0) );
136     delete THIS;
137
138 bool
139 wxAcceleratorTable::Ok()
140
141 #if WXPERL_W_VERSION_GE( 2, 8, 0 )
142
143 bool
144 wxAcceleratorTable::IsOk()
145
146 #endif