1998-05-20 10:25:30 -04:00
|
|
|
\section{\class{wxModule}}\label{wxmodule}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
The module system is a very simple mechanism to allow applications (and parts of wxWidgets itself) to
|
|
|
|
define initialization and cleanup functions that are automatically called on wxWidgets
|
1998-05-20 10:25:30 -04:00
|
|
|
startup and exit.
|
|
|
|
|
|
|
|
To define a new kind of module, derive a class from wxModule, override the OnInit and OnExit functions,
|
|
|
|
and add the DECLARE\_DYNAMIC\_CLASS and IMPLEMENT\_DYNAMIC\_CLASS to header and implementation files
|
2004-05-04 04:27:20 -04:00
|
|
|
(which can be the same file). On initialization, wxWidgets will find all classes derived from wxModule,
|
|
|
|
create an instance of each, and call each OnInit function. On exit, wxWidgets will call the OnExit
|
1998-05-20 10:25:30 -04:00
|
|
|
function for each module instance.
|
|
|
|
|
1999-01-25 13:33:08 -05:00
|
|
|
Note that your module class does not have to be in a header file.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
// A module to allow DDE initialization/cleanup
|
|
|
|
// without calling these functions from app.cpp or from
|
|
|
|
// the user's application.
|
|
|
|
|
|
|
|
class wxDDEModule: public wxModule
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDDEModule)
|
|
|
|
public:
|
|
|
|
wxDDEModule() {}
|
2003-01-17 19:16:34 -05:00
|
|
|
bool OnInit() { wxDDEInitialize(); return true; };
|
1999-01-25 13:33:08 -05:00
|
|
|
void OnExit() { wxDDECleanUp(); };
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxDDEModule, wxModule)
|
|
|
|
\end{verbatim}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
\helpref{wxObject}{wxobject}
|
|
|
|
|
1999-02-15 15:41:29 -05:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/module.h>
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
2004-09-27 12:01:38 -04:00
|
|
|
\membersection{wxModule::wxModule}\label{wxmodulector}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\func{}{wxModule}{\void}
|
|
|
|
|
|
|
|
Constructs a wxModule object.
|
|
|
|
|
2004-09-27 12:01:38 -04:00
|
|
|
\membersection{wxModule::\destruct{wxModule}}\label{wxmoduledtor}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\func{}{\destruct{wxModule}}{\void}
|
|
|
|
|
|
|
|
Destructor.
|
|
|
|
|
|
|
|
\membersection{wxModule::CleanupModules}\label{wxmodulecleanupmodules}
|
|
|
|
|
|
|
|
\func{static void}{CleanupModules}{\void}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Calls Exit for each module instance. Called by wxWidgets on exit, so there is no
|
1998-05-20 10:25:30 -04:00
|
|
|
need for an application to call it.
|
|
|
|
|
|
|
|
\membersection{wxModule::Exit}\label{wxmoduleexit}
|
|
|
|
|
|
|
|
\func{void}{Exit}{\void}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Calls OnExit. This function is called by wxWidgets and should not need to be called
|
1998-05-20 10:25:30 -04:00
|
|
|
by an application.
|
|
|
|
|
|
|
|
\membersection{wxModule::Init}\label{wxmoduleinit}
|
|
|
|
|
|
|
|
\func{bool}{Init}{\void}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Calls OnInit. This function is called by wxWidgets and should not need to be called
|
1998-05-20 10:25:30 -04:00
|
|
|
by an application.
|
|
|
|
|
|
|
|
\membersection{wxModule::InitializeModules}\label{wxmoduleinitializemodules}
|
|
|
|
|
|
|
|
\func{static bool}{InitializeModules}{\void}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Calls Init for each module instance. Called by wxWidgets on startup, so there is no
|
1998-05-20 10:25:30 -04:00
|
|
|
need for an application to call it.
|
|
|
|
|
|
|
|
\membersection{wxModule::OnExit}\label{wxmoduleonexit}
|
|
|
|
|
1998-10-02 08:50:01 -04:00
|
|
|
\func{virtual void}{OnExit}{\void}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Provide this function with appropriate cleanup for your module.
|
|
|
|
|
|
|
|
\membersection{wxModule::OnInit}\label{wxmoduleoninit}
|
|
|
|
|
|
|
|
\func{virtual bool}{OnInit}{\void}
|
|
|
|
|
|
|
|
Provide this function with appropriate initialization for your module. If the function
|
2004-05-04 04:27:20 -04:00
|
|
|
returns false, wxWidgets will exit immediately.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\membersection{wxModule::RegisterModule}\label{wxmoduleregistermodule}
|
|
|
|
|
|
|
|
\func{static void}{RegisterModule}{\param{wxModule*}{ module}}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Registers this module with wxWidgets. Called by wxWidgets on startup, so there is no
|
1998-05-20 10:25:30 -04:00
|
|
|
need for an application to call it.
|
|
|
|
|
|
|
|
\membersection{wxModule::RegisterModules}\label{wxmoduleregistermodules}
|
|
|
|
|
|
|
|
\func{static bool}{RegisterModules}{\void}
|
|
|
|
|
2004-05-04 04:27:20 -04:00
|
|
|
Creates instances of and registers all modules. Called by wxWidgets on startup, so there is no
|
1998-05-20 10:25:30 -04:00
|
|
|
need for an application to call it.
|
|
|
|
|