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