(1) Denis Pershin's patch for wxGTK (memory leaks corrections)
[wxWidgets.git] / include / wx / gtk / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef __GTKAPPH__
12 #define __GTKAPPH__
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "wx/window.h"
19 #include "wx/frame.h"
20
21 //-----------------------------------------------------------------------------
22 // classes
23 //-----------------------------------------------------------------------------
24
25 class wxApp;
26 class wxLog;
27
28 //-----------------------------------------------------------------------------
29 // global data
30 //-----------------------------------------------------------------------------
31
32 extern wxApp *wxTheApp;
33
34 //-----------------------------------------------------------------------------
35 // global functions
36 //-----------------------------------------------------------------------------
37
38 void wxExit(void);
39 bool wxYield(void);
40
41 //-----------------------------------------------------------------------------
42 // constants
43 //-----------------------------------------------------------------------------
44
45 #define wxPRINT_WINDOWS 1
46 #define wxPRINT_POSTSCRIPT 2
47
48 //-----------------------------------------------------------------------------
49 // wxApp
50 //-----------------------------------------------------------------------------
51
52 class wxApp: public wxEvtHandler
53 {
54 DECLARE_DYNAMIC_CLASS(wxApp)
55
56 public:
57
58 wxApp(void);
59 ~wxApp(void);
60
61 static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
62 static wxAppInitializerFunction GetInitializerFunction(void) { return m_appInitFn; }
63
64 virtual bool OnInit(void);
65 virtual bool OnInitGui(void);
66 virtual int OnRun(void);
67 virtual int OnExit(void);
68
69 wxWindow *GetTopWindow(void);
70 void SetTopWindow( wxWindow *win );
71 virtual int MainLoop(void);
72 void ExitMainLoop(void);
73 bool Initialized(void);
74 virtual bool Pending(void);
75 virtual void Dispatch(void);
76
77 inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
78 inline bool GetWantDebugOutput(void) { return m_wantDebugOutput; }
79
80 void OnIdle( wxIdleEvent &event );
81 bool SendIdleEvents(void);
82 bool SendIdleEvents( wxWindow* win );
83
84 inline wxString GetAppName(void) const {
85 if (m_appName != "")
86 return m_appName;
87 else return m_className;
88 }
89 inline void SetAppName(const wxString& name) { m_appName = name; };
90 inline wxString GetClassName(void) const { return m_className; }
91 inline void SetClassName(const wxString& name) { m_className = name; }
92 const wxString& GetVendorName() const { return m_vendorName; }
93 void SetVendorName(const wxString& name) { m_vendorName = name; }
94
95 inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
96 inline bool GetExitOnFrameDelete(void) const { return m_exitOnFrameDelete; }
97
98 void SetPrintMode(int WXUNUSED(mode) ) {};
99 int GetPrintMode(void) const { return wxPRINT_POSTSCRIPT; };
100
101 // override this function to create default log target of arbitrary
102 // user-defined classv (default implementation creates a wxLogGui object)
103 virtual wxLog *CreateLogTarget();
104
105 // GTK implementation
106
107 static void CommonInit(void);
108 static void CommonCleanUp(void);
109
110 bool ProcessIdle(void);
111 void DeletePendingObjects(void);
112
113 bool m_initialized;
114 bool m_exitOnFrameDelete;
115 bool m_wantDebugOutput;
116 wxWindow *m_topWindow;
117
118 gint m_idleTag;
119
120 int argc;
121 char **argv;
122
123 static wxAppInitializerFunction m_appInitFn;
124
125 private:
126 wxString m_vendorName,
127 m_appName,
128 m_className;
129
130 DECLARE_EVENT_TABLE()
131 };
132
133 #endif // __GTKAPPH__