]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/module.cpp
fixed serious bug in wxFont::operator== (ignored weight)
[wxWidgets.git] / src / common / module.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: module.cpp
3// Purpose: Modules initialization/destruction
4// Author: Wolfram Gloger/adapted by Guilhem Lavaux
5// Modified by:
6// Created: 04/11/98
7// RCS-ID: $Id$
8// Copyright: (c) Wolfram Gloger and Guilhem Lavaux
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "module.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#include "wx/module.h"
24#include "wx/hash.h"
25#include "wx/listimpl.cpp"
26
27#ifdef __SALFORDC__
28void wxwxModuleListNode::DeleteData()
29{
30 delete (_WX_LIST_ITEM_TYPE_wxModuleList *)GetData();
31}
32#else
33WX_DEFINE_LIST(wxModuleList);
34#endif
35
36IMPLEMENT_CLASS(wxModule, wxObject)
37
38wxModuleList wxModule::m_modules;
39
40void wxModule::RegisterModule(wxModule* module)
41{
42 m_modules.Append(module);
43}
44
45// Collect up all module-derived classes, create an instance of each,
46// and register them.
47void wxModule::RegisterModules()
48{
49 wxNode *node;
50 wxClassInfo* classInfo;
51
52 wxClassInfo::sm_classTable->BeginFind();
53 node = wxClassInfo::sm_classTable->Next();
54 while (node)
55 {
56 classInfo = (wxClassInfo *)node->Data();
57 if ( classInfo->IsKindOf(CLASSINFO(wxModule)) &&
58 (classInfo != (& (wxModule::sm_classwxModule))) )
59 {
60 wxModule* module = (wxModule *)classInfo->CreateObject();
61 RegisterModule(module);
62 }
63 node = wxClassInfo::sm_classTable->Next();
64 }
65}
66
67bool wxModule::InitializeModules()
68{
69 // Initialize user-defined modules
70 wxModuleList::Node *node;
71 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
72 {
73 if ( !node->GetData()->Init() )
74 {
75 // clean up already initialized modules - process in reverse order
76 wxModuleList::Node *n;
77 for ( n = node->GetPrevious(); n; n = n->GetPrevious() )
78 {
79 n->GetData()->OnExit();
80 }
81
82 return FALSE;
83 }
84 }
85
86 return TRUE;
87}
88
89void wxModule::CleanUpModules()
90{
91 // Cleanup user-defined modules
92 wxModuleList::Node *node;
93 for ( node = m_modules.GetFirst(); node; node = node->GetNext() )
94 {
95 node->GetData()->Exit();
96 }
97
98 m_modules.DeleteContents(TRUE);
99 m_modules.Clear();
100}
101