]>
Commit | Line | Data |
---|---|---|
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 | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_APP_H_ | |
13 | #define _WX_APP_H_ | |
14 | ||
15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
16 | #pragma interface "app.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/event.h" | |
20 | #include "wx/icon.h" | |
21 | ||
22 | class WXDLLIMPEXP_CORE wxFrame; | |
23 | class WXDLLIMPEXP_CORE wxWindow; | |
24 | class WXDLLIMPEXP_CORE wxApp; | |
25 | class WXDLLIMPEXP_CORE wxKeyEvent; | |
26 | class WXDLLIMPEXP_BASE wxLog; | |
27 | ||
28 | // Represents the application. Derive OnInit and declare | |
29 | // a new App object to start application | |
30 | class WXDLLEXPORT wxApp : public wxAppBase | |
31 | { | |
32 | DECLARE_DYNAMIC_CLASS(wxApp) | |
33 | ||
34 | public: | |
35 | wxApp(); | |
36 | virtual ~wxApp(); | |
37 | ||
38 | // override base class (pure) virtuals | |
39 | virtual bool Initialize(int& argc, wxChar **argv); | |
40 | virtual void CleanUp(); | |
41 | ||
42 | virtual bool Yield(bool onlyIfNeeded = FALSE); | |
43 | virtual void WakeUpIdle(); | |
44 | ||
45 | virtual void SetPrintMode(int mode) { m_printMode = mode; } | |
46 | virtual int GetPrintMode() const { return m_printMode; } | |
47 | ||
48 | // implementation only | |
49 | void OnIdle(wxIdleEvent& event); | |
50 | void OnEndSession(wxCloseEvent& event); | |
51 | void OnQueryEndSession(wxCloseEvent& event); | |
52 | ||
53 | #if wxUSE_EXCEPTIONS | |
54 | virtual bool OnExceptionInMainLoop(); | |
55 | #endif // wxUSE_EXCEPTIONS | |
56 | ||
57 | protected: | |
58 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT | |
59 | ||
60 | public: | |
61 | // Implementation | |
62 | static bool RegisterWindowClasses(); | |
63 | static bool UnregisterWindowClasses(); | |
64 | ||
65 | #if wxUSE_RICHEDIT | |
66 | // initialize the richedit DLL of (at least) given version, return TRUE if | |
67 | // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3) | |
68 | static bool InitRichEdit(int version = 2); | |
69 | #endif // wxUSE_RICHEDIT | |
70 | ||
71 | // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it | |
72 | // wasn't found at all | |
73 | static int GetComCtl32Version(); | |
74 | ||
75 | // the SW_XXX value to be used for the frames opened by the application | |
76 | // (currently seems unused which is a bug -- TODO) | |
77 | static int m_nCmdShow; | |
78 | ||
79 | protected: | |
80 | DECLARE_EVENT_TABLE() | |
81 | DECLARE_NO_COPY_CLASS(wxApp) | |
82 | }; | |
83 | ||
84 | // ---------------------------------------------------------------------------- | |
85 | // MSW-specific wxEntry() overload and IMPLEMENT_WXWIN_MAIN definition | |
86 | // ---------------------------------------------------------------------------- | |
87 | ||
88 | // we need HINSTANCE declaration to define WinMain() | |
89 | #include "wx/msw/wrapwin.h" | |
90 | ||
91 | #ifndef SW_SHOWNORMAL | |
92 | #define SW_SHOWNORMAL 1 | |
93 | #endif | |
94 | ||
95 | // WinMain() is always ANSI, even in Unicode build, under normal Windows | |
96 | // but is always Unicode under CE | |
97 | #ifdef __WXWINCE__ | |
98 | typedef wchar_t *wxCmdLineArgType; | |
99 | #else | |
100 | typedef char *wxCmdLineArgType; | |
101 | #endif | |
102 | ||
103 | extern int WXDLLEXPORT | |
104 | wxEntry(HINSTANCE hInstance, | |
105 | HINSTANCE hPrevInstance = NULL, | |
106 | wxCmdLineArgType pCmdLine = NULL, | |
107 | int nCmdShow = SW_SHOWNORMAL); | |
108 | ||
109 | #define IMPLEMENT_WXWIN_MAIN \ | |
110 | extern "C" int WINAPI WinMain(HINSTANCE hInstance, \ | |
111 | HINSTANCE hPrevInstance, \ | |
112 | wxCmdLineArgType lpCmdLine, \ | |
113 | int nCmdShow) \ | |
114 | { \ | |
115 | return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); \ | |
116 | } | |
117 | ||
118 | #endif // _WX_APP_H_ | |
119 |