]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/module.tex
wxFont can now raelly use the native fonts
[wxWidgets.git] / docs / latex / wx / module.tex
CommitLineData
a660d684
KB
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
e2a6f233
JS
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
a660d684
KB
34\wxheading{Derived from}
35
36\helpref{wxObject}{wxobject}
37
954b8ae6
JS
38\wxheading{Include files}
39
40<wx/module.h>
41
a660d684
KB
42\latexignore{\rtfignore{\wxheading{Members}}}
43
44\membersection{wxModule::wxModule}\label{wxmoduleconstr}
45
46\func{}{wxModule}{\void}
47
48Constructs a wxModule object.
49
50\membersection{wxModule::\destruct{wxModule}}
51
52\func{}{\destruct{wxModule}}{\void}
53
54Destructor.
55
56\membersection{wxModule::CleanupModules}\label{wxmodulecleanupmodules}
57
58\func{static void}{CleanupModules}{\void}
59
60Calls Exit for each module instance. Called by wxWindows on exit, so there is no
61need for an application to call it.
62
63\membersection{wxModule::Exit}\label{wxmoduleexit}
64
65\func{void}{Exit}{\void}
66
67Calls OnExit. This function is called by wxWindows and should not need to be called
68by an application.
69
70\membersection{wxModule::Init}\label{wxmoduleinit}
71
72\func{bool}{Init}{\void}
73
74Calls OnInit. This function is called by wxWindows and should not need to be called
75by an application.
76
77\membersection{wxModule::InitializeModules}\label{wxmoduleinitializemodules}
78
79\func{static bool}{InitializeModules}{\void}
80
81Calls Init for each module instance. Called by wxWindows on startup, so there is no
82need for an application to call it.
83
84\membersection{wxModule::OnExit}\label{wxmoduleonexit}
85
dfad0599 86\func{virtual void}{OnExit}{\void}
a660d684
KB
87
88Provide this function with appropriate cleanup for your module.
89
90\membersection{wxModule::OnInit}\label{wxmoduleoninit}
91
92\func{virtual bool}{OnInit}{\void}
93
94Provide this function with appropriate initialization for your module. If the function
95returns FALSE, wxWindows will exit immediately.
96
97\membersection{wxModule::RegisterModule}\label{wxmoduleregistermodule}
98
99\func{static void}{RegisterModule}{\param{wxModule*}{ module}}
100
101Registers this module with wxWindows. Called by wxWindows on startup, so there is no
102need for an application to call it.
103
104\membersection{wxModule::RegisterModules}\label{wxmoduleregistermodules}
105
106\func{static bool}{RegisterModules}{\void}
107
108Creates instances of and registers all modules. Called by wxWindows on startup, so there is no
109need for an application to call it.
110