X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a80e5f9e5b9d3d79865a0140caa714fafcd3808c..1981118d4bcd47bdbe4de66aba3e5db6368c7517:/include/wx/app.h diff --git a/include/wx/app.h b/include/wx/app.h index a06b1f7485..edd3eef488 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -75,6 +75,7 @@ private: }; #endif // wxUSE_GUI + // ---------------------------------------------------------------------------- // wxAppConsole: wxApp for non-GUI applications // ---------------------------------------------------------------------------- @@ -169,11 +170,13 @@ public: #if wxUSE_CMDLINE_PARSER // this one is called from OnInit() to add all supported options - // to the given parser + // to the given parser (don't forget to call the base class version if you + // override it!) virtual void OnInitCmdLine(wxCmdLineParser& parser); // called after successfully parsing the command line, return TRUE - // to continue and FALSE to exit + // to continue and FALSE to exit (don't forget to call the base class + // version if you override it!) virtual bool OnCmdLineParsed(wxCmdLineParser& parser); // called if "--help" option was specified, return TRUE to continue @@ -258,8 +261,14 @@ public: // check that the wxBuildOptions object (constructed in the application // itself, usually the one from IMPLEMENT_APP() macro) matches the build // options of the library and abort if it doesn't - static bool CheckBuildOptions(const wxBuildOptions& buildOptions); - + static bool CheckBuildOptions(const char *optionsSignature, + const char *componentName); +#if WXWIN_COMPATIBILITY_2_4 + static bool CheckBuildOptions(const wxBuildOptions& buildOptions) + { + return CheckBuildOptions(buildOptions.m_signature, "your program"); + } +#endif // implementation only from now on // ------------------------------- @@ -345,6 +354,9 @@ public: // Override: rarely in GUI applications, always in console ones. virtual int OnRun(); + // a matching function for OnInit() + virtual int OnExit(); + // very last clean up function // // Override: very rarely @@ -456,6 +468,14 @@ public: int GetPrintMode() const { return wxPRINT_POSTSCRIPT; } + // command line parsing (GUI-specific) + // ------------------------------------------------------------------------ + +#if wxUSE_CMDLINE_PARSER + virtual bool OnCmdLineParsed(wxCmdLineParser& parser); + virtual void OnInitCmdLine(wxCmdLineParser& parser); +#endif + // miscellaneous other stuff // ------------------------------------------------------------------------ @@ -577,19 +597,27 @@ public: // be in your main program (e.g. hello.cpp). Now IMPLEMENT_APP should add this // code if required. +#define IMPLEMENT_WXWIN_MAIN_CONSOLE \ + int main(int argc, char **argv) { return wxEntry(argc, argv); } + #if !wxUSE_GUI || !defined(__WXMSW__) #define IMPLEMENT_WXWIN_MAIN \ - int main(int argc, char **argv) { return wxEntry(argc, argv); } -#elif defined(__WXMSW__) && defined(WXUSINGDLL) + IMPLEMENT_WXWIN_MAIN_CONSOLE +#elif defined(__WXMSW__) // we need HINSTANCE declaration to define WinMain() - #include - #include "wx/msw/winundef.h" + #include "wx/msw/wrapwin.h" + + #ifdef SW_SHOWNORMAL + #define wxSW_SHOWNORMAL SW_SHOWNORMAL + #else + #define wxSW_SHOWNORMAL 0 + #endif #define IMPLEMENT_WXWIN_MAIN \ extern int wxEntry(HINSTANCE hInstance, \ HINSTANCE hPrevInstance = NULL, \ char *pCmdLine = NULL, \ - int nCmdShow = SW_NORMAL); \ + int nCmdShow = wxSW_SHOWNORMAL); \ extern "C" int WINAPI WinMain(HINSTANCE hInstance, \ HINSTANCE hPrevInstance, \ char *lpCmdLine, \ @@ -616,7 +644,8 @@ public: #define IMPLEMENT_APP_NO_MAIN(appname) \ wxAppConsole *wxCreateApp() \ { \ - wxAppConsole::CheckBuildOptions(wxBuildOptions()); \ + wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \ + "your program"); \ return new appname; \ } \ wxAppInitializer \ @@ -635,6 +664,11 @@ public: IMPLEMENT_APP_NO_THEMES(appname) \ IMPLEMENT_WX_THEME_SUPPORT +// Same as IMPLEMENT_APP(), but for console applications. +#define IMPLEMENT_APP_CONSOLE(appname) \ + IMPLEMENT_APP_NO_MAIN(appname) \ + IMPLEMENT_WXWIN_MAIN_CONSOLE + // this macro can be used multiple times and just allows you to use wxGetApp() // function #define DECLARE_APP(appname) extern appname& wxGetApp();