X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/954b8ae60391d18b87a604e7919c87c0c6ae208b..c944775f72435d2c0493113e05445898ab8baf1b:/docs/latex/wx/module.tex

diff --git a/docs/latex/wx/module.tex b/docs/latex/wx/module.tex
index bb515828dc..92a4349df1 100644
--- a/docs/latex/wx/module.tex
+++ b/docs/latex/wx/module.tex
@@ -1,14 +1,16 @@
 \section{\class{wxModule}}\label{wxmodule}
 
-The module system is a very simple mechanism to allow applications (and parts of wxWindows itself) to
-define initialization and cleanup functions that are automatically called on wxWindows
-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
-(which can be the same file). On initialization, wxWindows will find all classes derived from wxModule,
-create an instance of each, and call each OnInit function. On exit, wxWindows will call the OnExit
-function for each module instance.
+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.
 
 Note that your module class does not have to be in a header file.
 
@@ -18,17 +20,48 @@ For example:
   // 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() {}
-      bool OnInit() { wxDDEInitialize(); return TRUE; };
-      void OnExit() { wxDDECleanUp(); };
+      wxDDEModule() { }
+      virtual bool OnInit() { wxDDEInitialize(); return true; };
+      virtual void OnExit() { wxDDECleanUp(); };
+
+  private:
+      DECLARE_DYNAMIC_CLASS(wxDDEModule)
   };
 
   IMPLEMENT_DYNAMIC_CLASS(wxDDEModule, wxModule)
+
+
+  // Another module which uses DDE in its OnInit()
+  class MyModule: public wxModule
+  {
+  public:
+      MyModule() { AddDependency(CLASSINFO(wxDDEModule)); }
+      virtual bool OnInit() { ... code using DDE ... }
+      virtual void OnExit() { ... }
+
+  private:
+      DECLARE_DYNAMIC_CLASS(MyModule)
+  };
+
+  IMPLEMENT_DYNAMIC_CLASS(MyModule, wxModule)
+
+  // Another module which uses DDE in its OnInit()
+  // but uses a named dependency
+  class MyModule2: public wxModule
+  {
+  public:
+      MyModule2() { AddDependency("wxDDEModule"); }
+      virtual bool OnInit() { ... code using DDE ... }
+      virtual void OnExit() { ... }
+
+  private:
+      DECLARE_DYNAMIC_CLASS(MyModule2)
+  };
+
+  IMPLEMENT_DYNAMIC_CLASS(MyModule2, wxModule)
 \end{verbatim}
 
 \wxheading{Derived from}
@@ -39,47 +72,52 @@ For example:
 
 <wx/module.h>
 
+\wxheading{Library}
+
+\helpref{wxBase}{librarieslist}
+
 \latexignore{\rtfignore{\wxheading{Members}}}
 
-\membersection{wxModule::wxModule}\label{wxmoduleconstr}
+
+\membersection{wxModule::wxModule}\label{wxmodulector}
 
 \func{}{wxModule}{\void}
 
 Constructs a wxModule object.
 
-\membersection{wxModule::\destruct{wxModule}}
+
+\membersection{wxModule::\destruct{wxModule}}\label{wxmoduledtor}
 
 \func{}{\destruct{wxModule}}{\void}
 
 Destructor.
 
-\membersection{wxModule::CleanupModules}\label{wxmodulecleanupmodules}
-
-\func{static void}{CleanupModules}{\void}
 
-Calls Exit for each module instance. Called by wxWindows on exit, so there is no
-need for an application to call it.
+\membersection{wxModule::AddDependency}\label{wxmoduleadddependency}
 
-\membersection{wxModule::Exit}\label{wxmoduleexit}
+\func{void}{AddDependency}{\param{wxClassInfo * }{dep}}
 
-\func{void}{Exit}{\void}
+\func{void}{AddDependency}{\param{const char * }{classname}}
 
-Calls OnExit. This function is called by wxWindows and should not need to be called
-by an application.
+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.
 
-\membersection{wxModule::Init}\label{wxmoduleinit}
+The second version of this function allows a dependency to be added by
+name without access to the class info.  This is useful when a module is
+declared entirely in a source file and there is no header for the declaration
+of the module needed by \helpref{CLASSINFO}{classinfo}, however errors are
+not detected until run-time, instead of compile-time, then.
 
-\func{bool}{Init}{\void}
+Note that circular dependencies are detected and result in a fatal error.
 
-Calls OnInit. This function is called by wxWindows and should not need to be called
-by an application.
+\wxheading{Parameters}
 
-\membersection{wxModule::InitializeModules}\label{wxmoduleinitializemodules}
+\docparam{dep}{The class information object for the dependent module.}
 
-\func{static bool}{InitializeModules}{\void}
+\docparam{classname}{The class name of the dependent module.}
 
-Calls Init for each module instance. Called by wxWindows on startup, so there is no
-need for an application to call it.
 
 \membersection{wxModule::OnExit}\label{wxmoduleonexit}
 
@@ -87,24 +125,11 @@ need for an application to call it.
 
 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
-returns FALSE, wxWindows will exit immediately.
-
-\membersection{wxModule::RegisterModule}\label{wxmoduleregistermodule}
-
-\func{static void}{RegisterModule}{\param{wxModule*}{ module}}
-
-Registers this module with wxWindows. Called by wxWindows on startup, so there is no
-need for an application to call it.
-
-\membersection{wxModule::RegisterModules}\label{wxmoduleregistermodules}
-
-\func{static bool}{RegisterModules}{\void}
-
-Creates instances of and registers all modules. Called by wxWindows on startup, so there is no
-need for an application to call it.
+returns false, wxWidgets will exit immediately.
 
