1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * John C. Griggs <johng@corel.com>.
19 * Portions created by the Initial Developer are Copyright (C) 2000
20 * the Initial Developer. All Rights Reserved.
23 * Zack Rusin <zack@kde.org>
24 * Lars Knoll <knoll@kde.org>
25 * John C. Griggs <johng@corel.com>
26 * Dan Rosen <dr@netscape.com>
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
43 #include "nsAppShell.h"
45 #include "mozilla/ModuleUtils.h"
46 #include "nsIModule.h"
49 #include "nsWidgetsCID.h"
50 #include "nsToolkit.h"
51 #include "nsHTMLFormatConverter.h"
52 #include "nsTransferable.h"
53 #include "nsLookAndFeel.h"
54 #include "nsAppShellSingleton.h"
55 #include "nsScreenManagerQt.h"
56 #include "nsFilePicker.h"
57 #include "nsClipboard.h"
58 #include "nsClipboardHelper.h"
59 #include "nsIdleServiceQt.h"
60 #include "nsDragService.h"
62 #include "nsBidiKeyboard.h"
63 #include "nsNativeThemeQt.h"
65 #include "nsDeviceContextSpecQt.h"
66 #include "nsPrintSession.h"
67 #include "nsPrintOptionsQt.h"
68 #include "nsPrintDialogQt.h"
71 #include "nsFilePickerProxy.h"
72 #include "nsXULAppAPI.h"
76 extern PRBool gDisableNativeTheme
;
78 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow
)
79 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildWindow
)
80 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPopupWindow
)
81 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit
)
82 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter
)
83 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable
)
84 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel
)
85 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerQt
)
86 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard
)
87 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper
)
88 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService
)
89 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard
)
90 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceQt
)
91 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound
)
94 nsFilePickerConstructor(nsISupports
*aOuter
, REFNSIID aIID
,
98 if (aOuter
!= nsnull
) {
99 return NS_ERROR_NO_AGGREGATION
;
101 nsCOMPtr
<nsIFilePicker
> picker
;
104 if (XRE_GetProcessType() == GeckoProcessType_Content
)
105 picker
= new nsFilePickerProxy();
108 picker
= new nsFilePicker
;
110 return picker
->QueryInterface(aIID
, aResult
);
115 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQt
)
116 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsQt
, Init
)
117 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorQt
)
118 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession
, Init
)
119 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceQt
, Init
)
123 nsNativeThemeQtConstructor(nsISupports
*aOuter
, REFNSIID aIID
,
127 nsNativeThemeQt
*inst
;
129 if (gDisableNativeTheme
)
130 return NS_ERROR_NO_INTERFACE
;
134 return NS_ERROR_NO_AGGREGATION
;
136 inst
= new nsNativeThemeQt();
138 return NS_ERROR_OUT_OF_MEMORY
;
141 rv
= inst
->QueryInterface(aIID
, aResult
);
147 NS_DEFINE_NAMED_CID(NS_WINDOW_CID
);
148 NS_DEFINE_NAMED_CID(NS_CHILD_CID
);
149 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID
);
150 NS_DEFINE_NAMED_CID(NS_LOOKANDFEEL_CID
);
151 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID
);
152 NS_DEFINE_NAMED_CID(NS_SOUND_CID
);
153 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID
);
154 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID
);
155 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID
);
156 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID
);
157 NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID
);
158 NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID
);
159 NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID
);
160 NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID
);
161 NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID
);
162 NS_DEFINE_NAMED_CID(NS_POPUP_CID
);
163 NS_DEFINE_NAMED_CID(NS_TOOLKIT_CID
);
165 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID
);
166 NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID
);
167 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID
);
168 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID
);
169 NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID
);
172 static const mozilla::Module::CIDEntry kWidgetCIDs
[] = {
173 { &kNS_WINDOW_CID
, false, NULL
, nsWindowConstructor
},
174 { &kNS_CHILD_CID
, false, NULL
, nsChildWindowConstructor
},
175 { &kNS_APPSHELL_CID
, false, NULL
, nsAppShellConstructor
},
176 { &kNS_LOOKANDFEEL_CID
, false, NULL
, nsLookAndFeelConstructor
},
177 { &kNS_FILEPICKER_CID
, false, NULL
, nsFilePickerConstructor
},
178 { &kNS_SOUND_CID
, false, NULL
, nsSoundConstructor
},
179 { &kNS_TRANSFERABLE_CID
, false, NULL
, nsTransferableConstructor
},
180 { &kNS_CLIPBOARD_CID
, false, NULL
, nsClipboardConstructor
},
181 { &kNS_CLIPBOARDHELPER_CID
, false, NULL
, nsClipboardHelperConstructor
},
182 { &kNS_DRAGSERVICE_CID
, false, NULL
, nsDragServiceConstructor
},
183 { &kNS_HTMLFORMATCONVERTER_CID
, false, NULL
, nsHTMLFormatConverterConstructor
},
184 { &kNS_BIDIKEYBOARD_CID
, false, NULL
, nsBidiKeyboardConstructor
},
185 { &kNS_SCREENMANAGER_CID
, false, NULL
, nsScreenManagerQtConstructor
},
186 { &kNS_THEMERENDERER_CID
, false, NULL
, nsNativeThemeQtConstructor
},
187 { &kNS_IDLE_SERVICE_CID
, false, NULL
, nsIdleServiceQtConstructor
},
188 { &kNS_POPUP_CID
, false, NULL
, nsPopupWindowConstructor
},
189 { &kNS_TOOLKIT_CID
, false, NULL
, nsToolkitConstructor
},
191 { &kNS_PRINTSETTINGSSERVICE_CID
, false, NULL
, nsPrintOptionsQtConstructor
},
192 { &kNS_PRINTER_ENUMERATOR_CID
, false, NULL
, nsPrinterEnumeratorQtConstructor
},
193 { &kNS_PRINTSESSION_CID
, false, NULL
, nsPrintSessionConstructor
},
194 { &kNS_DEVICE_CONTEXT_SPEC_CID
, false, NULL
, nsDeviceContextSpecQtConstructor
},
195 { &kNS_PRINTDIALOGSERVICE_CID
, false, NULL
, nsPrintDialogServiceQtConstructor
},
200 static const mozilla::Module::ContractIDEntry kWidgetContracts
[] = {
201 { "@mozilla.org/widget/window/qt;1", &kNS_WINDOW_CID
},
202 { "@mozilla.org/widgets/child_window/qt;1", &kNS_CHILD_CID
},
203 { "@mozilla.org/widget/appshell/qt;1", &kNS_APPSHELL_CID
},
204 { "@mozilla.org/widget/lookandfeel;1", &kNS_LOOKANDFEEL_CID
},
205 { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID
},
206 { "@mozilla.org/sound;1", &kNS_SOUND_CID
},
207 { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID
},
208 { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID
},
209 { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID
},
210 { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID
},
211 { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID
},
212 { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID
},
213 { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID
},
214 { "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID
},
215 { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID
},
216 { "@mozilla.org/widgets/popup_window/qt;1", &kNS_POPUP_CID
},
217 { "@mozilla.org/widget/toolkit/qt;1", &kNS_TOOLKIT_CID
},
219 { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID
},
220 { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID
},
221 { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID
},
222 { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID
},
223 { NS_PRINTDIALOGSERVICE_CONTRACTID
, &kNS_PRINTDIALOGSERVICE_CID
},
229 nsWidgetQtModuleDtor()
232 nsWindow::ReleaseGlobals();
233 nsAppShellShutdown();
236 static const mozilla::Module kWidgetModule
= {
237 mozilla::Module::kVersion
,
246 NSMODULE_DEFN(nsWidgetQtModule
) = &kWidgetModule
;