1998-05-20 14:25:30 +00:00
|
|
|
\section{\class{wxModule}}\label{wxmodule}
|
|
|
|
|
2006-06-11 22:19:12 +00: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 startup and exit.
|
|
|
|
|
|
|
|
To define a new kind of module, derive a class from wxModule, override the
|
|
|
|
\helpref{OnInit}{wxmoduleoninit} and \helpref{OnExit}{wxmoduleonexit}
|
|
|
|
functions, and add the DECLARE\_DYNAMIC\_CLASS and IMPLEMENT\_DYNAMIC\_CLASS to
|
|
|
|
header and implementation files (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 function for each module instance.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
1999-01-25 18:33:08 +00: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
|
|
|
|
{
|
|
|
|
public:
|
2006-06-11 22:19:12 +00:00
|
|
|
wxDDEModule() { }
|
|
|
|
virtual bool OnInit() { wxDDEInitialize(); return true; };
|
|
|
|
virtual void OnExit() { wxDDECleanUp(); };
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDDEModule)
|
1999-01-25 18:33:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxDDEModule, wxModule)
|
2006-06-11 22:19:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Another module which uses DDE in its OnInit()
|
|
|
|
class MyModule: public wxModule
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxDDEModule() { AddDependency(CLASSINFO(wxDDEModule)); }
|
|
|
|
virtual bool OnInit() { ... code using DDE ... }
|
|
|
|
virtual void OnExit() { ... }
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDDEModule)
|
|
|
|
};
|
1999-01-25 18:33:08 +00:00
|
|
|
\end{verbatim}
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
\helpref{wxObject}{wxobject}
|
|
|
|
|
1999-02-15 20:41:29 +00:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/module.h>
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
2006-06-11 22:19:12 +00:00
|
|
|
|
2004-09-27 16:01:38 +00:00
|
|
|
\membersection{wxModule::wxModule}\label{wxmodulector}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{}{wxModule}{\void}
|
|
|
|
|
|
|
|
Constructs a wxModule object.
|
|
|
|
|
2006-06-11 22:19:12 +00:00
|
|
|
|
2004-09-27 16:01:38 +00:00
|
|
|
\membersection{wxModule::\destruct{wxModule}}\label{wxmoduledtor}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{}{\destruct{wxModule}}{\void}
|
|
|
|
|
|
|
|
Destructor.
|
|
|
|
|
2006-06-11 22:19:12 +00:00
|
|
|
|
|
|
|
\membersection{wxModule::AddDependency}\label{wxmoduleoninit}
|
|
|
|
|
|
|
|
\func{void}{AddDependency}{\param{wxClassInfo * }{dep}}
|
|
|
|
|
|
|
|
Call this function from the constructor of the derived class. \arg{dep} must be
|
|
|
|
the \helpref{CLASSINFO}{classinfo} of a wxModule-derived class and the
|
|
|
|
corresponding module will be loaded \emph{before} and unloaded \emph{after}
|
|
|
|
this module.
|
|
|
|
|
|
|
|
Note that circular dependencies are detected and result in a fatal error.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{dep}{The class information object for the dependent module.}
|
|
|
|
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\membersection{wxModule::OnExit}\label{wxmoduleonexit}
|
|
|
|
|
1998-10-02 12:50:01 +00:00
|
|
|
\func{virtual void}{OnExit}{\void}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
Provide this function with appropriate cleanup for your module.
|
|
|
|
|
2006-06-11 22:19:12 +00:00
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\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 08:27:20 +00:00
|
|
|
returns false, wxWidgets will exit immediately.
|
2006-10-10 17:46:49 +00:00
|
|
|
|