Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / cpp / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        cpp/app.h
3 // Purpose:     c++ wrapper for wxApp
4 // Author:      Mattia Barbon
5 // Modified by:
6 // Created:     29/10/2000
7 // RCS-ID:      $Id: app.h 2057 2007-06-18 23:03:00Z mbarbon $
8 // Copyright:   (c) 2000-2006 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 #ifdef Yield
14 #undef Yield
15 #endif
16
17 class wxPliApp:public wxApp
18 {
19     WXPLI_DECLARE_DYNAMIC_CLASS( wxPliApp );
20     WXPLI_DECLARE_V_CBACK();
21 public:
22     wxPliApp( const char* package = "Wx::App" );
23     ~wxPliApp();
24
25     bool OnInit();
26     int MainLoop();
27     void CleanUp() { DeletePendingObjects( this ); wxApp::CleanUp(); }
28
29 #if defined( __WXMSW__ ) && WXPERL_W_VERSION_LT( 2, 5, 0 )
30     static void SetKeepGoing(wxPliApp* app, bool value)
31     {
32         app->m_keepGoing = value;
33     }
34 #endif
35
36     void DeletePendingObjects() {
37         wxApp::DeletePendingObjects();
38     }
39
40     static void DeletePendingObjects(wxApp* app)
41     {
42         ((wxPliApp*) app)->DeletePendingObjects();
43     }
44
45     DEC_V_CBACK_INT__VOID( OnExit );
46     DEC_V_CBACK_BOOL__BOOL( Yield );
47 };
48
49 inline wxPliApp::wxPliApp( const char* package )
50     :m_callback( "Wx::App" ) 
51 {
52     m_callback.SetSelf( wxPli_make_object( this, package ), true );
53 }
54
55 wxPliApp::~wxPliApp()
56 {
57 #ifdef __WXMOTIF__
58     if (GetTopWindow())
59     {
60         delete GetTopWindow();
61         SetTopWindow(NULL);
62     }
63
64     DeletePendingObjects();
65
66     OnExit();
67 #endif
68 #if WXPERL_W_VERSION_LE( 2, 5, 1 )
69     wxPli_delete_argv( (void***) &argv, 1 );
70
71     argc = 0;
72     argv = 0;
73 #endif
74 }
75
76 inline bool wxPliApp::OnInit() 
77 {
78     wxApp::OnInit();
79
80     return false;
81 }
82
83 inline int wxPliApp::MainLoop() {
84     int retval = 0;
85   
86     DeletePendingObjects();
87 #if defined( __WXGTK__ ) && WXPERL_W_VERSION_LT( 2, 5, 1 )
88     m_initialized = wxTopLevelWindows.GetCount() != 0;
89 #endif
90
91     if( m_exitOnFrameDelete == Later )
92       m_exitOnFrameDelete = Yes;
93     retval = wxApp::MainLoop();
94     OnExit();
95
96     return retval;
97 }
98
99 DEF_V_CBACK_INT__VOID( wxPliApp, wxApp, OnExit );
100 DEF_V_CBACK_BOOL__BOOL( wxPliApp, wxApp, Yield );
101
102 WXPLI_IMPLEMENT_DYNAMIC_CLASS( wxPliApp, wxApp );
103
104 // Local variables: //
105 // mode: c++ //
106 // End: //