Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / cpp / singlechoicedialog.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        cpp/singlechoicedialog.h
3 // Purpose:     c++ wrapper for wxSingleChoiceDialog
4 // Author:      Mattia Barbon
5 // Modified by:
6 // Created:     11/02/2001
7 // RCS-ID:      $Id: singlechoicedialog.h 2057 2007-06-18 23:03:00Z mbarbon $
8 // Copyright:   (c) 2001-2002 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 // increments reference count of client data upon construction,
14 // and decrements it upon destruction
15 class wxPliSingleChoiceDialog:public wxSingleChoiceDialog
16 {
17 public:
18     wxPliSingleChoiceDialog( wxWindow* parent, const wxString& message,
19                              const wxString& caption, int n,
20                              const wxString* choices, SV** clientdata,
21                              long style, const wxPoint& pos );
22     ~wxPliSingleChoiceDialog();
23 private:
24     SV** m_data;
25     int m_num;
26 };
27
28 inline wxPliSingleChoiceDialog::wxPliSingleChoiceDialog
29     ( wxWindow* parent, const wxString& message, const wxString& caption,
30       int n, const wxString* choices, SV** clientdata, long style,
31       const wxPoint& pos )
32     :wxSingleChoiceDialog( parent, message, caption, n, choices,
33                            (char**)clientdata, style, pos ),
34     m_data(0)
35 {
36     dTHX;
37     if( clientdata )
38     {
39         int i;
40
41         for( i = 0; i < n; ++i )
42         {
43             SvREFCNT_inc( clientdata[i] );
44         }
45
46         m_data = new SV*[ n ];
47         m_num = n;
48         memcpy( m_data, clientdata, n * sizeof( SV* ) );
49     }
50 }
51
52 inline wxPliSingleChoiceDialog::~wxPliSingleChoiceDialog()
53 {
54     dTHX;
55     if( m_data )
56     {
57         int i;
58
59         for( i = 0; i < m_num; ++i )
60         {
61             SvREFCNT_dec( m_data[i] );
62         }
63
64         delete[] m_data;
65     }
66 }
67
68 // Local variables: //
69 // mode: c++ //
70 // End: //