CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / src / os2 / nsWidgetFactory.cpp
blobff8e0182669b2c334d297fd80d0cf1160c2067ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK *****
39 * This Original Code has been modified by IBM Corporation.
40 * Modifications made by IBM described herein are
41 * Copyright (c) International Business Machines
42 * Corporation, 2000
44 * Modifications to Mozilla code or documentation
45 * identified per MPL Section 3.3
47 * Date Modified by Description of modification
48 * 03/23/2000 IBM Corp. Added support for directory picker dialog.
49 * 03/24/2000 IBM Corp. Updated based on nsWinWidgetFactory.cpp.
50 * 05/31/2000 IBM Corp. Enabled timer stuff
51 * 06/30/2000 sobotka@axess.com Added nsFilePicker
52 * 03/11/2001 achimha@innotek.de converted to XPCOM module
53 * 03/20/2001 achimha@innotek.de Added class for embedded module init
54 * 12/16/2001 pavlov@netscape.com Removed timer stuff
57 #include "mozilla/ModuleUtils.h"
58 #include "nsIModule.h"
59 #include "nsCOMPtr.h"
60 #include "nsWidgetsCID.h"
62 // class definition headers
63 #include "nsAppShell.h"
64 #include "nsAppShellSingleton.h"
65 #include "nsBidiKeyboard.h"
66 #include "nsWindow.h"
67 #include "nsDragService.h"
68 #include "nsILocalFile.h"
69 #include "nsFilePicker.h"
70 #include "nsLookAndFeel.h"
71 #include "nsSound.h"
72 #include "nsToolkit.h"
74 // Drag & Drop, Clipboard
75 #include "nsClipboard.h"
76 #include "nsClipboardHelper.h"
77 #include "nsTransferable.h"
78 #include "nsHTMLFormatConverter.h"
80 #include "nsScreenManagerOS2.h"
81 #include "nsRwsService.h"
83 // Printing
84 #include "nsDeviceContextSpecOS2.h"
85 #include "nsPrintOptionsOS2.h"
86 #include "nsPrintSession.h"
87 #include "nsIdleServiceOS2.h"
89 // objects that just require generic constructors
90 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
91 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
92 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
93 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
94 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
95 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildWindow)
96 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
97 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
98 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
99 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
100 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
101 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
103 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecOS2)
104 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsOS2, Init)
105 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorOS2)
106 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
107 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerOS2)
108 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceOS2)
110 // component definition, will be exported using XPCOM
111 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
112 NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
113 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
114 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
115 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
116 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
117 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
118 NS_DEFINE_NAMED_CID(NS_LOOKANDFEEL_CID);
119 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
120 NS_DEFINE_NAMED_CID(NS_TOOLKIT_CID);
121 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
122 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
123 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
124 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
125 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
126 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
127 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
128 NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
129 NS_DEFINE_NAMED_CID(NS_RWSSERVICE_CID);
130 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
133 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
134 { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
135 { &kNS_BIDIKEYBOARD_CID, false, NULL, nsBidiKeyboardConstructor },
136 { &kNS_CHILD_CID, false, NULL, nsChildWindowConstructor },
137 { &kNS_CLIPBOARD_CID, false, NULL, nsClipboardConstructor },
138 { &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor },
139 { &kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor },
140 { &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor },
141 { &kNS_LOOKANDFEEL_CID, false, NULL, nsLookAndFeelConstructor },
142 { &kNS_SOUND_CID, false, NULL, nsSoundConstructor },
143 { &kNS_TOOLKIT_CID, false, NULL, nsToolkitConstructor },
144 { &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
145 { &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
146 { &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
147 { &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerOS2Constructor },
148 { &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecOS2Constructor },
149 { &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsOS2Constructor },
150 { &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
151 { &kNS_PRINTER_ENUMERATOR_CID, false, NULL, nsPrinterEnumeratorOS2Constructor },
152 { &kNS_RWSSERVICE_CID, false, NULL, nsRwsServiceConstructor },
153 { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceOS2Constructor },
154 { NULL }
157 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
158 { "@mozilla.org/widget/appshell/os2;1", &kNS_APPSHELL_CID },
159 { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
160 { "@mozilla.org/widget/child_window/os2;1", &kNS_CHILD_CID },
161 { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID },
162 { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
163 { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID },
164 { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID },
165 { "@mozilla.org/widget/lookandfeel;1", &kNS_LOOKANDFEEL_CID },
166 { "@mozilla.org/sound;1", &kNS_SOUND_CID },
167 { "@mozilla.org/widget/toolkit/os2;1", &kNS_TOOLKIT_CID },
168 { "@mozilla.org/widget/window/os2;1", &kNS_WINDOW_CID },
169 { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
170 { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
171 { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
172 { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
173 { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
174 { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
175 { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID },
176 { NS_RWSSERVICE_CONTRACTID, &kNS_RWSSERVICE_CID },
177 { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
178 { NULL }
181 static void
182 nsWidgetOS2ModuleDtor()
184 nsWindow::ReleaseGlobals();
185 nsFilePicker::ReleaseGlobals();
186 nsAppShellShutdown();
189 static const mozilla::Module kWidgetModule = {
190 mozilla::Module::kVersion,
191 kWidgetCIDs,
192 kWidgetContracts,
193 NULL,
194 NULL,
195 nsAppShellInit,
196 nsWidgetOS2ModuleDtor
199 NSMODULE_DEFN(nsWidgetOS2Module) = &kWidgetModule;