]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/module.tex
a bit more docs
[wxWidgets.git] / docs / latex / wx / module.tex
... / ...
CommitLineData
1\section{\class{wxModule}}\label{wxmodule}
2
3The module system is a very simple mechanism to allow applications (and parts of wxWindows itself) to
4define initialization and cleanup functions that are automatically called on wxWindows
5startup and exit.
6
7To define a new kind of module, derive a class from wxModule, override the OnInit and OnExit functions,
8and add the DECLARE\_DYNAMIC\_CLASS and IMPLEMENT\_DYNAMIC\_CLASS to header and implementation files
9(which can be the same file). On initialization, wxWindows will find all classes derived from wxModule,
10create an instance of each, and call each OnInit function. On exit, wxWindows will call the OnExit
11function for each module instance.
12
13Note that your module class does not have to be in a header file.
14
15For example:
16
17\begin{verbatim}
18 // A module to allow DDE initialization/cleanup
19 // without calling these functions from app.cpp or from
20 // the user's application.
21
22 class wxDDEModule: public wxModule
23 {
24 DECLARE_DYNAMIC_CLASS(wxDDEModule)
25 public:
26 wxDDEModule() {}
27 bool OnInit() { wxDDEInitialize(); return TRUE; };
28 void OnExit() { wxDDECleanUp(); };
29 };
30
31 IMPLEMENT_DYNAMIC_CLASS(wxDDEModule, wxModule)
32\end{verbatim}
33
34\wxheading{Derived from}
35
36\helpref{wxObject}{wxobject}
37
38\latexignore{\rtfignore{\wxheading{Members}}}
39
40\membersection{wxModule::wxModule}\label{wxmoduleconstr}
41
42\func{}{wxModule}{\void}
43
44Constructs a wxModule object.
45
46\membersection{wxModule::\destruct{wxModule}}
47
48\func{}{\destruct{wxModule}}{\void}
49
50Destructor.
51
52\membersection{wxModule::CleanupModules}\label{wxmodulecleanupmodules}
53
54\func{static void}{CleanupModules}{\void}
55
56Calls Exit for each module instance. Called by wxWindows on exit, so there is no
57need for an application to call it.
58
59\membersection{wxModule::Exit}\label{wxmoduleexit}
60
61\func{void}{Exit}{\void}
62
63Calls OnExit. This function is called by wxWindows and should not need to be called
64by an application.
65
66\membersection{wxModule::Init}\label{wxmoduleinit}
67
68\func{bool}{Init}{\void}
69
70Calls OnInit. This function is called by wxWindows and should not need to be called
71by an application.
72
73\membersection{wxModule::InitializeModules}\label{wxmoduleinitializemodules}
74
75\func{static bool}{InitializeModules}{\void}
76
77Calls Init for each module instance. Called by wxWindows on startup, so there is no
78need for an application to call it.
79
80\membersection{wxModule::OnExit}\label{wxmoduleonexit}
81
82\func{virtual void}{OnExit}{\void}
83
84Provide this function with appropriate cleanup for your module.
85
86\membersection{wxModule::OnInit}\label{wxmoduleoninit}
87
88\func{virtual bool}{OnInit}{\void}
89
90Provide this function with appropriate initialization for your module. If the function
91returns FALSE, wxWindows will exit immediately.
92
93\membersection{wxModule::RegisterModule}\label{wxmoduleregistermodule}
94
95\func{static void}{RegisterModule}{\param{wxModule*}{ module}}
96
97Registers this module with wxWindows. Called by wxWindows on startup, so there is no
98need for an application to call it.
99
100\membersection{wxModule::RegisterModules}\label{wxmoduleregistermodules}
101
102\func{static bool}{RegisterModules}{\void}
103
104Creates instances of and registers all modules. Called by wxWindows on startup, so there is no
105need for an application to call it.
106