]>
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" | |
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 | ||
2bda0e17 | 33 | // Force an exit from main loop |
bb6290e3 | 34 | void WXDLLEXPORT wxExit(); |
2bda0e17 KB |
35 | |
36 | // Yield to other apps/messages | |
bb6290e3 | 37 | bool WXDLLEXPORT wxYield(); |
2bda0e17 KB |
38 | |
39 | // Represents the application. Derive OnInit and declare | |
40 | // a new App object to start application | |
41 | class WXDLLEXPORT wxApp: public wxEvtHandler | |
42 | { | |
43 | DECLARE_DYNAMIC_CLASS(wxApp) | |
bb6290e3 | 44 | wxApp(); |
589f0e3e | 45 | ~wxApp(); |
2bda0e17 KB |
46 | |
47 | static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; } | |
bb6290e3 | 48 | static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; } |
2bda0e17 | 49 | |
bb6290e3 JS |
50 | virtual int MainLoop(); |
51 | void ExitMainLoop(); | |
52 | bool Initialized(); | |
53 | virtual bool Pending() ; | |
54 | virtual void Dispatch() ; | |
2bda0e17 | 55 | |
7f555861 | 56 | void OnIdle(wxIdleEvent& event); |
2bda0e17 | 57 | |
2bda0e17 | 58 | // Generic |
bb6290e3 | 59 | virtual bool OnInit() { return FALSE; }; |
2bda0e17 KB |
60 | |
61 | // No specific tasks to do here. | |
bb6290e3 | 62 | virtual bool OnInitGui() { return TRUE; } |
2bda0e17 KB |
63 | |
64 | // Called to set off the main loop | |
bb6290e3 | 65 | virtual int OnRun() { return MainLoop(); }; |
580c10e3 VZ |
66 | virtual int OnExit() { return 0; } |
67 | ||
2bda0e17 | 68 | inline void SetPrintMode(int mode) { m_printMode = mode; } |
bb6290e3 | 69 | inline int GetPrintMode() const { return m_printMode; } |
2bda0e17 | 70 | |
bb6290e3 JS |
71 | inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; } |
72 | inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; } | |
2bda0e17 | 73 | |
bb6290e3 | 74 | inline wxString GetAppName() const { |
2bda0e17 KB |
75 | if (m_appName != "") |
76 | return m_appName; | |
77 | else return m_className; | |
78 | } | |
79 | ||
80 | inline void SetAppName(const wxString& name) { m_appName = name; }; | |
bb6290e3 | 81 | inline wxString GetClassName() const { return m_className; } |
2bda0e17 | 82 | inline void SetClassName(const wxString& name) { m_className = name; } |
580c10e3 VZ |
83 | |
84 | void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; } | |
85 | const wxString& GetVendorName() const { return m_vendorName; } | |
86 | ||
bb6290e3 | 87 | wxWindow *GetTopWindow() const ; |
2bda0e17 KB |
88 | inline void SetTopWindow(wxWindow *win) { m_topWindow = win; } |
89 | ||
90 | inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; } | |
bb6290e3 | 91 | inline bool GetWantDebugOutput() { return m_wantDebugOutput; } |
2bda0e17 KB |
92 | |
93 | // Send idle event to all top-level windows. | |
94 | // Returns TRUE if more idle time is requested. | |
bb6290e3 | 95 | bool SendIdleEvents(); |
2bda0e17 KB |
96 | |
97 | // Send idle event to window and all subwindows | |
98 | // Returns TRUE if more idle time is requested. | |
99 | bool SendIdleEvents(wxWindow* win); | |
100 | ||
debe6624 | 101 | inline void SetAuto3D(bool flag) { m_auto3D = flag; } |
bb6290e3 | 102 | inline bool GetAuto3D() const { return m_auto3D; } |
2bda0e17 KB |
103 | |
104 | // Creates a log object | |
4e066dd2 VZ |
105 | virtual wxLog* CreateLogTarget(); |
106 | ||
2bda0e17 KB |
107 | public: |
108 | // void (*work_proc)(wxApp*app); // work procedure; | |
109 | int argc; | |
110 | char ** argv; | |
111 | ||
112 | protected: | |
113 | bool m_wantDebugOutput ; | |
114 | wxString m_className; | |
580c10e3 VZ |
115 | wxString m_appName, |
116 | m_vendorName; | |
2bda0e17 KB |
117 | wxWindow * m_topWindow; |
118 | bool m_exitOnFrameDelete; | |
119 | bool m_showOnInit; | |
120 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT | |
121 | bool m_auto3D ; // Always use 3D controls, except | |
122 | // where overriden | |
123 | static wxAppInitializerFunction m_appInitFn; | |
124 | ||
125 | /* Windows-specific wxApp definitions */ | |
126 | ||
127 | public: | |
128 | ||
129 | // Implementation | |
589f0e3e | 130 | static bool Initialize(); |
bb6290e3 | 131 | static void CleanUp(); |
589f0e3e JS |
132 | |
133 | static bool RegisterWindowClasses(); | |
134 | // Convert Windows to argc, argv style | |
135 | void ConvertToStandardCommandArgs(char* p); | |
bb6290e3 | 136 | virtual bool DoMessage(); |
2bda0e17 | 137 | virtual bool ProcessMessage(WXMSG* pMsg); |
bb6290e3 JS |
138 | void DeletePendingObjects(); |
139 | bool ProcessIdle(); | |
140 | int GetComCtl32Version() const; | |
2bda0e17 KB |
141 | |
142 | public: | |
143 | static long sm_lastMessageTime; | |
144 | int m_nCmdShow; | |
145 | ||
146 | protected: | |
147 | bool m_keepGoing ; | |
2bda0e17 KB |
148 | |
149 | DECLARE_EVENT_TABLE() | |
150 | }; | |
151 | ||
152 | #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) | |
153 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance, WXHINSTANCE hPrevInstance, char *lpszCmdLine, | |
154 | int nCmdShow, bool enterLoop = TRUE); | |
155 | #else | |
156 | int WXDLLEXPORT wxEntry(WXHINSTANCE hInstance); | |
157 | #endif | |
158 | ||
159 | #endif | |
bbcdf8bc | 160 | // _WX_APP_H_ |
2bda0e17 | 161 |