]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: app.h | |
3 | // Purpose: wxApp class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_APP_H_ |
13 | #define _WX_APP_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
16 | #pragma interface "app.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/object.h" | |
a3ef5bf5 | 21 | #include "wx/event.h" |
2bda0e17 KB |
22 | |
23 | class WXDLLEXPORT wxFrame; | |
24 | class WXDLLEXPORT wxWindow; | |
25 | class WXDLLEXPORT wxApp ; | |
26 | class WXDLLEXPORT wxKeyEvent; | |
27 | class WXDLLEXPORT wxLog; | |
28 | ||
29 | #define wxPRINT_WINDOWS 1 | |
30 | #define wxPRINT_POSTSCRIPT 2 | |
31 | ||
32 | WXDLLEXPORT_DATA(extern wxApp*) wxTheApp; | |
33 | ||
2bda0e17 | 34 | // Force an exit from main loop |
bb6290e3 | 35 | void WXDLLEXPORT wxExit(); |
2bda0e17 KB |
36 | |
37 | // Yield to other apps/messages | |
bb6290e3 | 38 | bool WXDLLEXPORT wxYield(); |
2bda0e17 KB |
39 | |
40 | // Represents the application. Derive OnInit and declare | |
41 | // a new App object to start application | |
42 | class WXDLLEXPORT wxApp: public wxEvtHandler | |
43 | { | |
44 | DECLARE_DYNAMIC_CLASS(wxApp) | |
bb6290e3 | 45 | wxApp(); |
589f0e3e | 46 | ~wxApp(); |
2bda0e17 KB |
47 | |
48 | static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; } | |
bb6290e3 | 49 | static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; } |
2bda0e17 | 50 | |
bb6290e3 JS |
51 | virtual int MainLoop(); |
52 | void ExitMainLoop(); | |
53 | bool Initialized(); | |
54 | virtual bool Pending() ; | |
55 | virtual void Dispatch() ; | |
2bda0e17 | 56 | |
7f555861 | 57 | void OnIdle(wxIdleEvent& event); |
387a3b02 JS |
58 | void OnEndSession(wxCloseEvent& event); |
59 | void OnQueryEndSession(wxCloseEvent& event); | |
2bda0e17 | 60 | |
c085e333 | 61 | // Generic |
bb6290e3 | 62 | virtual bool OnInit() { return FALSE; }; |
2bda0e17 KB |
63 | |
64 | // No specific tasks to do here. | |
bb6290e3 | 65 | virtual bool OnInitGui() { return TRUE; } |
2bda0e17 KB |
66 | |
67 | // Called to set off the main loop | |
bb6290e3 | 68 | virtual int OnRun() { return MainLoop(); }; |
580c10e3 VZ |
69 | virtual int OnExit() { return 0; } |
70 | ||
c085e333 VZ |
71 | // called when a fatal exception occurs, this function should take care not |
72 | // to do anything which might provoke a nested exception! | |
73 | virtual void OnFatalException() { } | |
74 | ||
2bda0e17 | 75 | inline void SetPrintMode(int mode) { m_printMode = mode; } |
bb6290e3 | 76 | inline int GetPrintMode() const { return m_printMode; } |
2bda0e17 | 77 | |
bb6290e3 JS |
78 | inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; } |
79 | inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; } | |
2bda0e17 | 80 | |
c1b2075d | 81 | inline const wxString& GetAppName() const { |
39ca6d79 | 82 | if (m_appName != _T("")) |
2bda0e17 KB |
83 | return m_appName; |
84 | else return m_className; | |
85 | } | |
86 | ||
87 | inline void SetAppName(const wxString& name) { m_appName = name; }; | |
bb6290e3 | 88 | inline wxString GetClassName() const { return m_className; } |
2bda0e17 | 89 | inline void SetClassName(const wxString& name) { m_className = name; } |
580c10e3 VZ |
90 | |
91 | void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; } | |
92 | const wxString& GetVendorName() const { return m_vendorName; } | |
93 | ||
bb6290e3 | 94 | wxWindow *GetTopWindow() const ; |
2bda0e17 KB |
95 | inline void SetTopWindow(wxWindow *win) { m_topWindow = win; } |
96 | ||
97 | inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; } | |
bb6290e3 | 98 | inline bool GetWantDebugOutput() { return m_wantDebugOutput; } |
2bda0e17 KB |
99 | |
100 | // Send idle event to all top-level windows. | |
101 | // Returns TRUE if more idle time is requested. | |
bb6290e3 | 102 | bool SendIdleEvents(); |
2bda0e17 KB |
103 | |
104 | // Send idle event to window and all subwindows | |
105 | // Returns TRUE if more idle time is requested. | |
106 | bool SendIdleEvents(wxWindow* win); | |
107 | ||
debe6624 | 108 | inline void SetAuto3D(bool flag) { m_auto3D = flag; } |
bb6290e3 | 109 | inline bool GetAuto3D() const { return m_auto3D; } |
2bda0e17 KB |
110 | |
111 | // Creates a log object | |
4e066dd2 VZ |
112 | virtual wxLog* CreateLogTarget(); |
113 | ||
2bda0e17 KB |
114 | public: |
115 | // void (*work_proc)(wxApp*app); // work procedure; | |
116 | int argc; | |
117 | char ** argv; | |
118 | ||
119 | protected: | |
120 | bool m_wantDebugOutput ; | |
121 | wxString m_className; | |
580c10e3 VZ |
122 | wxString m_appName, |
123 | m_vendorName; | |
2bda0e17 KB |
124 | wxWindow * m_topWindow; |
125 | bool m_exitOnFrameDelete; | |
126 | bool m_showOnInit; | |
127 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT | |
128 | bool m_auto3D ; // Always use 3D controls, except | |
129 | // where overriden | |
130 | static wxAppInitializerFunction m_appInitFn; | |
131 | ||
132 | /* Windows-specific wxApp definitions */ | |
133 | ||
134 | public: | |
135 | ||
136 | // Implementation | |
589f0e3e | 137 | static bool Initialize(); |
bb6290e3 | 138 | static void CleanUp(); |
589f0e3e JS |
139 | |
140 | static bool RegisterWindowClasses(); | |
141 | // Convert Windows to argc, argv style | |
142 | void ConvertToStandardCommandArgs(char* p); | |
bb6290e3 | 143 | virtual bool DoMessage(); |
2bda0e17 | 144 | virtual bool ProcessMessage(WXMSG* pMsg); |
bb6290e3 JS |
145 | void DeletePendingObjects(); |
146 | bool ProcessIdle(); | |
7214297d GL |
147 | #if wxUSE_THREADS |
148 | void ProcessPendingEvents(); | |
149 | #endif | |
bb6290e3 | 150 | int GetComCtl32Version() const; |
2bda0e17 KB |
151 | |
152 | public: | |
153 | static long sm_lastMessageTime; | |
154 | int m_nCmdShow; | |
155 | ||
156 | protected: | |
157 | bool m_keepGoing ; | |
2bda0e17 KB |
158 | |
159 | DECLARE_EVENT_TABLE() | |
160 | }; | |
161 | ||
162 | #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) | |
163 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine, | |
164 | int nCmdShow, bool enterLoop = TRUE); | |
165 | #else | |
166 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance); | |
167 | #endif | |
168 | ||
169 | #endif | |
bbcdf8bc | 170 | // _WX_APP_H_ |
2bda0e17 | 171 |