Back to index

lightning-sunbird  0.9+nobinonly
nsGfxFactoryQt.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Christopher Blizzard.
00018  * Portions created by the Initial Developer are Copyright (C) 2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Lars Knoll <knoll@kde.org>
00023  *   Zack Rusin <zack@kde.org>
00024  *   John C. Griggs <johng@corel.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "nsIGenericFactory.h"
00041 #include "nsIModule.h"
00042 #include "nsCOMPtr.h"
00043 #include "nsGfxCIID.h"
00044 
00045 #include "nsBlender.h"
00046 #include "nsFontMetricsQt.h"
00047 #include "nsRenderingContextQt.h"
00048 #include "nsDeviceContextSpecQt.h"
00049 #include "nsDeviceContextSpecFactoryQt.h"
00050 #include "nsScreenManagerQt.h"
00051 #include "nsScriptableRegion.h"
00052 #include "nsDeviceContextQt.h"
00053 #include "nsImageQt.h"
00054 #include "nsFontList.h"
00055 #include "nsPrintSession.h"
00056 #include "nsNativeThemeQt.h"
00057 #include "gfxImageFrame.h"
00058 
00059 #include "qtlog.h"
00060 
00061 // Initialize qt logging
00062 PRLogModuleInfo *gQtLogModule = PR_NewLogModule("QtGfx");
00063 
00064 // objects that just require generic constructors
00065 
00066 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsQt)
00067 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextQt)
00068 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextQt)
00069 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageQt)
00070 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
00071 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionQt)
00072 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQt)
00073 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryQt)
00074 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorQt)
00075 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
00076 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerQt)
00077 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
00078 NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
00079 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeQt)
00080 
00081 // our custom constructors
00082 static nsresult nsScriptableRegionConstructor(nsISupports *aOuter,REFNSIID aIID,void **aResult)
00083 {
00084     nsresult rv;
00085 
00086     nsIScriptableRegion *inst = 0;
00087 
00088     if (NULL == aResult) {
00089         rv = NS_ERROR_NULL_POINTER;
00090         return rv;
00091     }
00092     *aResult = NULL;
00093     if (NULL != aOuter) {
00094         rv = NS_ERROR_NO_AGGREGATION;
00095         return rv;
00096     }
00097     // create an nsRegionQt and get the scriptable region from it
00098     nsCOMPtr <nsIRegion> rgn;
00099     NS_NEWXPCOM(rgn, nsRegionQt);
00100     if (rgn != nsnull) {
00101         nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
00102         inst = scriptableRgn;
00103     }
00104     if (NULL == inst) {
00105         rv = NS_ERROR_OUT_OF_MEMORY;
00106         return rv;
00107     }
00108     NS_ADDREF(inst);
00109     rv = inst->QueryInterface(aIID, aResult);
00110     NS_RELEASE(inst);
00111 
00112     return rv;
00113 }
00114 
00115 static const nsModuleComponentInfo components[] =
00116 {
00117     { "Qt Font Metrics",
00118       NS_FONT_METRICS_CID,
00119       "@mozilla.org/gfx/fontmetrics;1",
00120       nsFontMetricsQtConstructor },
00121     { "Qt Device Context",
00122       NS_DEVICE_CONTEXT_CID,
00123       "@mozilla.org/gfx/devicecontext;1",
00124       nsDeviceContextQtConstructor },
00125     { "Qt Rendering Context",
00126       NS_RENDERING_CONTEXT_CID,
00127       "@mozilla.org/gfx/renderingcontext;1",
00128       nsRenderingContextQtConstructor },
00129     { "Qt Image",
00130       NS_IMAGE_CID,
00131       "@mozilla.org/gfx/image;1",
00132       nsImageQtConstructor },
00133     { "Qt Region",
00134       NS_REGION_CID,
00135       "@mozilla.org/gfx/region/qt;1",
00136       nsRegionQtConstructor },
00137     { "Scriptable Region",
00138       NS_SCRIPTABLE_REGION_CID,
00139       "@mozilla.org/gfx/region;1",
00140       nsScriptableRegionConstructor },
00141     { "Blender",
00142       NS_BLENDER_CID,
00143       "@mozilla.org/gfx/blender;1",
00144       nsBlenderConstructor },
00145     { "Qt Device Context Spec",
00146       NS_DEVICE_CONTEXT_SPEC_CID,
00147       "@mozilla.org/gfx/devicecontextspec;1",
00148       nsDeviceContextSpecQtConstructor },
00149     { "Qt Device Context Spec Factory",
00150       NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
00151       "@mozilla.org/gfx/devicecontextspecfactory;1",
00152       nsDeviceContextSpecFactoryQtConstructor },
00153     { "Qt Font Enumerator",
00154       NS_FONT_ENUMERATOR_CID,
00155       "@mozilla.org/gfx/fontenumerator;1",
00156       nsFontEnumeratorQtConstructor },
00157     { "Font List",
00158       NS_FONTLIST_CID,
00159       //    "@mozilla.org/gfx/fontlist;1"
00160       NS_FONTLIST_CONTRACTID,
00161       nsFontListConstructor },
00162     { "Qt Screen Manager",
00163       NS_SCREENMANAGER_CID,
00164       "@mozilla.org/gfx/screenmanager;1",
00165       nsScreenManagerQtConstructor },
00166     { "shared image frame",
00167       GFX_IMAGEFRAME_CID,
00168       "@mozilla.org/gfx/image/frame;2",
00169       gfxImageFrameConstructor, },
00170     { "Native Theme Renderer",
00171       NS_THEMERENDERER_CID,
00172       "@mozilla.org/chrome/chrome-native-theme;1",
00173       nsNativeThemeQtConstructor },
00174     { "Print Session",
00175       NS_PRINTSESSION_CID,
00176       "@mozilla.org/gfx/printsession;1",
00177       nsPrintSessionConstructor }
00178 };
00179 
00180 NS_IMPL_NSGETMODULE(nsGfxQtModule, components)
00181