CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / src / cocoa / nsWidgetFactory.mm
blobfb9282b436fb84cca05ad2cc17eed052da859b8a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is mozilla.org code.
16  *
17  * The Initial Developer of the Original Code is
18  * Netscape Communications Corporation.
19  * Portions created by the Initial Developer are Copyright (C) 1998
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the MPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
38 #include "nsIFactory.h"
39 #include "nsISupports.h"
40 #include "nsIComponentManager.h"
41 #include "mozilla/ModuleUtils.h"
43 #include "nsWidgetsCID.h"
45 #include "nsToolkit.h"
46 #include "nsChildView.h"
47 #include "nsCocoaWindow.h"
48 #include "nsAppShell.h"
49 #include "nsAppShellSingleton.h"
50 #include "nsFilePicker.h"
52 #include "nsClipboard.h"
53 #include "nsClipboardHelper.h"
54 #include "nsTransferable.h"
55 #include "nsHTMLFormatConverter.h"
56 #include "nsDragService.h"
58 #include "nsLookAndFeel.h"
60 #include "nsSound.h"
61 #include "nsIdleServiceX.h"
63 #include "nsScreenManagerCocoa.h"
64 #include "nsDeviceContextSpecX.h"
65 #include "nsPrintOptionsX.h"
66 #include "nsPrintDialogX.h"
67 #include "nsPrintSession.h"
69 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
70 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
71 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
72 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
73 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
74 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
75 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
76 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
77 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
78 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
79 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
80 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
81 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
82 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
83 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceX, Init)
84 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
85 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceX)
87 #include "nsMenuBarX.h"
88 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeMenuServiceX)
90 #include "nsBidiKeyboard.h"
91 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
93 #include "nsNativeThemeCocoa.h"
94 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeCocoa)
96 #include "nsMacDockSupport.h"
97 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacDockSupport)
99 #include "nsStandaloneNativeMenu.h"
100 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandaloneNativeMenu)
102 #include "GfxInfo.h"
103 namespace mozilla {
104 namespace widget {
105 // This constructor should really be shared with all platforms.
106 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
111 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
112 NS_DEFINE_NAMED_CID(NS_POPUP_CID);
113 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
114 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
115 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
116 NS_DEFINE_NAMED_CID(NS_TOOLKIT_CID);
117 NS_DEFINE_NAMED_CID(NS_LOOKANDFEEL_CID);
118 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
119 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
120 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
121 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
122 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
123 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
124 NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
125 NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID);
126 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
127 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
128 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
129 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
130 NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
131 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
132 NS_DEFINE_NAMED_CID(NS_NATIVEMENUSERVICE_CID);
133 NS_DEFINE_NAMED_CID(NS_MACDOCKSUPPORT_CID);
134 NS_DEFINE_NAMED_CID(NS_STANDALONENATIVEMENU_CID);
135 NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
138 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
139   { &kNS_WINDOW_CID, false, NULL, nsCocoaWindowConstructor },
140   { &kNS_POPUP_CID, false, NULL, nsCocoaWindowConstructor },
141   { &kNS_CHILD_CID, false, NULL, nsChildViewConstructor },
142   { &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor },
143   { &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
144   { &kNS_TOOLKIT_CID, false, NULL, nsToolkitConstructor },
145   { &kNS_LOOKANDFEEL_CID, false, NULL, nsLookAndFeelConstructor },
146   { &kNS_SOUND_CID, false, NULL, nsSoundConstructor },
147   { &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
148   { &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
149   { &kNS_CLIPBOARD_CID, false, NULL, nsClipboardConstructor },
150   { &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor },
151   { &kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor },
152   { &kNS_BIDIKEYBOARD_CID, false, NULL, nsBidiKeyboardConstructor },
153   { &kNS_THEMERENDERER_CID, false, NULL, nsNativeThemeCocoaConstructor },
154   { &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerCocoaConstructor },
155   { &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor },
156   { &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
157   { &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsXConstructor },
158   { &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor },
159   { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceXConstructor },
160   { &kNS_NATIVEMENUSERVICE_CID, false, NULL, nsNativeMenuServiceXConstructor },
161   { &kNS_MACDOCKSUPPORT_CID, false, NULL, nsMacDockSupportConstructor },
162   { &kNS_STANDALONENATIVEMENU_CID, false, NULL, nsStandaloneNativeMenuConstructor },
163   { &kNS_GFXINFO_CID, false, NULL, mozilla::widget::GfxInfoConstructor },
164   { NULL }
167 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
168   { "@mozilla.org/widgets/window/mac;1", &kNS_WINDOW_CID },
169   { "@mozilla.org/widgets/popup/mac;1", &kNS_POPUP_CID },
170   { "@mozilla.org/widgets/childwindow/mac;1", &kNS_CHILD_CID },
171   { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID },
172   { "@mozilla.org/widget/appshell/mac;1", &kNS_APPSHELL_CID },
173   { "@mozilla.org/widget/toolkit/mac;1", &kNS_TOOLKIT_CID },
174   { "@mozilla.org/widget/lookandfeel;1", &kNS_LOOKANDFEEL_CID },
175   { "@mozilla.org/sound;1", &kNS_SOUND_CID },
176   { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
177   { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
178   { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID },
179   { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
180   { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID },
181   { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
182   { "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
183   { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
184   { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
185   { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
186   { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
187   { NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
188   { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
189   { "@mozilla.org/widget/nativemenuservice;1", &kNS_NATIVEMENUSERVICE_CID },
190   { "@mozilla.org/widget/macdocksupport;1", &kNS_MACDOCKSUPPORT_CID },
191   { "@mozilla.org/widget/standalonenativemenu;1", &kNS_STANDALONENATIVEMENU_CID },
192   { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
193   { NULL }
196 static const mozilla::Module kWidgetModule = {
197   mozilla::Module::kVersion,
198   kWidgetCIDs,
199   kWidgetContracts,
200   NULL,
201   NULL,
202   nsAppShellInit,
203   nsAppShellShutdown
206 NSMODULE_DEFN(nsWidgetMacModule) = &kWidgetModule;