X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5f4f5b58f6557eedf795696cca090e2308f329a9..a893b65e6282e4b96126b3fd22eeab43d446be4b:/include/wx/app.h diff --git a/include/wx/app.h b/include/wx/app.h index 4eae440186..4fc847b33c 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -34,13 +34,7 @@ class WXDLLIMPEXP_BASE wxCmdLineParser; class WXDLLIMPEXP_BASE wxLog; class WXDLLIMPEXP_BASE wxMessageOutput; -// wxUSE_EVTLOOP_IN_APP is a temporary hack needed until all ports are updated -// to use wxEventLoop, otherwise we get linking errors on wxMac, it's going to -// disappear a.s.a.p. -#ifdef __WXMAC__ - #define wxUSE_EVTLOOP_IN_APP 0 -#else - #define wxUSE_EVTLOOP_IN_APP 1 +#if wxUSE_GUI class WXDLLEXPORT wxEventLoop; #endif @@ -116,20 +110,6 @@ public: // crash. virtual void OnFatalException() { } -#if wxUSE_EXCEPTIONS - // function called if an uncaught exception is caught inside the main - // event loop: it may return true to continue running the event loop or - // false to stop it (in the latter case it may rethrow the exception as - // well) - virtual bool OnExceptionInMainLoop(); - - // Called when an unhandled C++ exception occurs inside OnRun(): note that - // the exception type is lost by now, so if you really want to handle the - // exception you should override OnRun() and put a try/catch around - // MainLoop() call there - virtual void OnUnhandledException() { } -#endif // wxUSE_EXCEPTIONS - // Called from wxExit() function, should terminate the application a.s.a.p. virtual void Exit(); @@ -206,12 +186,12 @@ public: // user-defined class (default implementation creates a wxLogGui // object) -- this log object is used by default by all wxLogXXX() // functions. - virtual wxLog *CreateLogTarget(); + wxDEPRECATED( virtual wxLog *CreateLogTarget() ); #endif // wxUSE_LOG // similar to CreateLogTarget() but for the global wxMessageOutput // object - virtual wxMessageOutput *CreateMessageOutput(); + wxDEPRECATED( virtual wxMessageOutput *CreateMessageOutput() ); #endif // WXWIN_COMPATIBILITY_2_4 @@ -237,6 +217,12 @@ public: virtual void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const; + + // Called when an unhandled C++ exception occurs inside OnRun(): note that + // the exception type is lost by now, so if you really want to handle the + // exception you should override OnRun() and put a try/catch around + // MainLoop() call there or use OnExceptionInMainLoop() + virtual void OnUnhandledException() { } #endif // wxUSE_EXCEPTIONS // process all events in the wxPendingEvents list -- it is necessary to @@ -251,17 +237,30 @@ public: // make sure that idle events are sent again virtual void WakeUpIdle() { } + // this is just a convenience: by providing its implementation here we + // avoid #ifdefs in the code using it + static bool IsMainLoopRunning() { return false; } + // debugging support // ----------------- +#ifdef __WXDEBUG__ // this function is called when an assert failure occurs, the base class // version does the normal processing (i.e. shows the usual assert failure // dialog box) // - // the arguments are the place where the assert occured, the text of the + // the arguments are the location of the failed assert (func may be empty + // if the compiler doesn't support C99 __FUNCTION__), the text of the // assert itself and the user-specified message -#ifdef __WXDEBUG__ + virtual void OnAssertFailure(const wxChar *file, + int line, + const wxChar *func, + const wxChar *cond, + const wxChar *msg); + + // old version of the function without func parameter, for compatibility + // only, override OnAssertFailure() in the new code virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, @@ -274,10 +273,7 @@ public: 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"); - } + wxDEPRECATED( static bool CheckBuildOptions(const wxBuildOptions& buildOptions) ); #endif // implementation only from now on @@ -378,13 +374,10 @@ public: // return true if we're running main loop, i.e. if the events can // (already) be dispatched - bool IsMainLoopRunning() const + static bool IsMainLoopRunning() { -#if wxUSE_EVTLOOP_IN_APP - return m_mainLoop != NULL; -#else - return false; -#endif + wxAppBase *app = wx_static_cast(wxAppBase *, GetInstance()); + return app && app->m_mainLoop != NULL; } // execute the main GUI loop, the function returns when the loop ends @@ -428,8 +421,14 @@ public: // Returns true if more idle time is requested. virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event); - // Perform standard OnIdle behaviour: call from port's OnIdle - void OnIdle(wxIdleEvent& event); + +#if wxUSE_EXCEPTIONS + // Function called if an uncaught exception is caught inside the main + // event loop: it may return true to continue running the event loop or + // false to stop it (in the latter case it may rethrow the exception as + // well) + virtual bool OnExceptionInMainLoop(); +#endif // wxUSE_EXCEPTIONS // top level window functions @@ -504,10 +503,15 @@ public: // deactivated virtual void SetActive(bool isActive, wxWindow *lastFocus); +#if WXWIN_COMPATIBILITY_2_6 // OBSOLETE: don't use, always returns true // // returns true if the program is successfully initialized - bool Initialized() { return true; } + wxDEPRECATED( bool Initialized() ); +#endif // WXWIN_COMPATIBILITY_2_6 + + // perform standard OnIdle behaviour, ensure that this is always called + void OnIdle(wxIdleEvent& event); protected: @@ -518,11 +522,9 @@ protected: virtual wxAppTraits *CreateTraits(); -#if wxUSE_EVTLOOP_IN_APP // the main event loop of the application (may be NULL if the loop hasn't // been started yet or has already terminated) wxEventLoop *m_mainLoop; -#endif // wxUSE_EVTLOOP_IN_APP // the main top level window (may be NULL) wxWindow *m_topWindow; @@ -538,17 +540,21 @@ protected: Yes } m_exitOnFrameDelete; - // true if the apps whats to use the best visual on systems where + // true if the app wants to use the best visual on systems where // more than one are available (Sun, SGI, XFree86 4.0 ?) bool m_useBestVisual; - // does any of our windows has focus? + // does any of our windows have focus? bool m_isActive; DECLARE_NO_COPY_CLASS(wxAppBase) }; +#if WXWIN_COMPATIBILITY_2_6 + inline bool wxAppBase::Initialized() { return true; } +#endif // WXWIN_COMPATIBILITY_2_6 + #endif // wxUSE_GUI // ---------------------------------------------------------------------------- @@ -556,14 +562,18 @@ protected: // ---------------------------------------------------------------------------- #if wxUSE_GUI - #if defined(__WXMSW__) + #if defined(__WXPALMOS__) + #include "wx/palmos/app.h" + #elif defined(__WXMSW__) #include "wx/msw/app.h" #elif defined(__WXMOTIF__) #include "wx/motif/app.h" #elif defined(__WXMGL__) #include "wx/mgl/app.h" - #elif defined(__WXGTK__) + #elif defined(__WXGTK20__) #include "wx/gtk/app.h" + #elif defined(__WXGTK__) + #include "wx/gtk1/app.h" #elif defined(__WXX11__) #include "wx/x11/app.h" #elif defined(__WXMAC__) @@ -631,7 +641,7 @@ public: #define IMPLEMENT_WXWIN_MAIN_CONSOLE \ int main(int argc, char **argv) { return wxEntry(argc, argv); } -// port-specific header could have defined it already in some special wau +// port-specific header could have defined it already in some special way #ifndef IMPLEMENT_WXWIN_MAIN #define IMPLEMENT_WXWIN_MAIN IMPLEMENT_WXWIN_MAIN_CONSOLE #endif // defined(IMPLEMENT_WXWIN_MAIN) @@ -657,6 +667,7 @@ public: } \ wxAppInitializer \ wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ + DECLARE_APP(appname) \ appname& wxGetApp() { return *(appname *)wxTheApp; } // Same as IMPLEMENT_APP() normally but doesn't include themes support in @@ -680,5 +691,12 @@ public: // function #define DECLARE_APP(appname) extern appname& wxGetApp(); -#endif // _WX_APP_H_BASE_ +// declare the stuff defined by IMPLEMENT_APP() macro, it's not really needed +// anywhere else but at the very least it suppresses icc warnings about +// defining extern symbols without prior declaration, and it shouldn't do any +// harm +extern wxAppConsole *wxCreateApp(); +extern wxAppInitializer wxTheAppInitializer; + +#endif // _WX_APP_H_BASE_