Back to index

lightning-sunbird  0.9+nobinonly
nsGfxFactoryMac.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Patrick C. Beard <beard@netscape.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nscore.h"
00040 #include "nsIFactory.h"
00041 #include "nsISupports.h"
00042 #include "nsIFontList.h"
00043 #include "nsGfxCIID.h"
00044 #include "nsFontList.h"
00045 #include "nsFontMetricsMac.h"
00046 #include "nsRenderingContextMac.h"
00047 #include "nsImageMac.h"
00048 #include "nsDeviceContextMac.h"
00049 #include "nsRegionMac.h"
00050 #include "nsScriptableRegion.h"
00051 #include "nsNativeThemeMac.h"
00052 #include "nsDeviceContextSpecX.h"
00053 #include "nsPrintOptionsX.h"
00054 #include "nsPrintSessionX.h"
00055 #include "nsDeviceContextSpecFactoryM.h"
00056 #include "nsScreenManagerMac.h"
00057 #include "nsBlender.h"
00058 #include "nsCOMPtr.h"
00059 #include "nsUnicodeMappingUtil.h"
00060 #include "gfxImageFrame.h"
00061 #ifdef MOZ_WIDGET_COCOA
00062 #include "nsQDFlushManager.h"
00063 #endif
00064 
00065 #include "nsIGenericFactory.h"
00066 
00067 
00068 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsMac)
00069 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextMac)
00070 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextMac)
00071 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageMac)
00072 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionMac)
00073 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
00074 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceMac)
00075 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
00076 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
00077 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
00078 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac)
00079 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorMac)
00080 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
00081 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac)
00082 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeMac)
00083 NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
00084 #ifdef MOZ_WIDGET_COCOA
00085 NS_GENERIC_FACTORY_CONSTRUCTOR(nsQDFlushManager)
00086 #endif
00087 
00088 static NS_IMETHODIMP
00089 nsScriptableRegionConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
00090 {
00091   NS_ENSURE_NO_AGGREGATION(aOuter);
00092   NS_ENSURE_ARG_POINTER(aResult);
00093   *aResult = nsnull;
00094   nsCOMPtr<nsIRegion> region = new nsRegionMac();
00095   NS_ENSURE_TRUE(region, NS_ERROR_OUT_OF_MEMORY);
00096   nsCOMPtr<nsIScriptableRegion> result(new nsScriptableRegion(region));
00097   NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
00098   return result->QueryInterface(aIID, aResult);
00099 }
00100 
00101 static const nsModuleComponentInfo components[] =
00102 {
00103   { "nsFontMetrics",
00104     NS_FONT_METRICS_CID,
00105     "@mozilla.org/gfx/fontmetrics;1",
00106     nsFontMetricsMacConstructor },
00107   { "nsDeviceContext",
00108     NS_DEVICE_CONTEXT_CID,
00109     "@mozilla.org/gfx/devicecontext;1",
00110     nsDeviceContextMacConstructor },
00111   { "nsRenderingContext",
00112     NS_RENDERING_CONTEXT_CID,
00113     "@mozilla.org/gfx/renderingcontext;1",
00114     nsRenderingContextMacConstructor },
00115   { "nsImage",
00116     NS_IMAGE_CID,
00117     "@mozilla.org/gfx/image;1",
00118     nsImageMacConstructor },
00119   { "nsRegion",
00120     NS_REGION_CID,
00121     "@mozilla.org/gfx/unscriptable-region;1",
00122     nsRegionMacConstructor },
00123   { "nsScriptableRegion",
00124     NS_SCRIPTABLE_REGION_CID,
00125     "@mozilla.org/gfx/region;1",
00126     nsScriptableRegionConstructor },
00127   { "nsBlender",
00128     NS_BLENDER_CID,
00129     "@mozilla.org/gfx/blender;1",
00130     nsBlenderConstructor },
00131   { "nsDrawingSurface",
00132     NS_DRAWING_SURFACE_CID,
00133     "@mozilla.org/gfx/drawing-surface;1",
00134     nsDrawingSurfaceMacConstructor },
00135   { "nsDeviceContextSpec",
00136     NS_DEVICE_CONTEXT_SPEC_CID,
00137     "@mozilla.org/gfx/devicecontextspec;1",
00138     nsDeviceContextSpecXConstructor },
00139   { "nsDeviceContextSpecFactory",
00140     NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
00141     "@mozilla.org/gfx/devicecontextspecfactory;1",
00142     nsDeviceContextSpecFactoryMacConstructor },
00143   { "PrintSettings Service",
00144     NS_PRINTSETTINGSSERVICE_CID,
00145     "@mozilla.org/gfx/printsettings-service;1",
00146     nsPrintOptionsXConstructor },
00147   { "Print Session",
00148     NS_PRINTSESSION_CID,
00149     "@mozilla.org/gfx/printsession;1",
00150     nsPrintSessionXConstructor },
00151   { "nsFontEnumerator",
00152     NS_FONT_ENUMERATOR_CID,
00153     "@mozilla.org/gfx/fontenumerator;1",
00154     nsFontEnumeratorMacConstructor },
00155   { "nsFontList",
00156     NS_FONTLIST_CID,
00157     "@mozilla.org/gfx/fontlist;1",
00158     nsFontListConstructor },
00159   { "nsScreenManager",
00160     NS_SCREENMANAGER_CID,
00161     "@mozilla.org/gfx/screenmanager;1",
00162     nsScreenManagerMacConstructor },
00163   { "windows image frame",
00164     GFX_IMAGEFRAME_CID,
00165     "@mozilla.org/gfx/image/frame;2",
00166     gfxImageFrameConstructor, },
00167   { "Native Theme Renderer", 
00168     NS_THEMERENDERER_CID,
00169     "@mozilla.org/chrome/chrome-native-theme;1", 
00170     nsNativeThemeMacConstructor },
00171 #ifdef MOZ_WIDGET_COCOA
00172   { NS_QDFLUSHMANAGER_CLASSNAME,
00173     NS_QDFLUSHMANAGER_CID,
00174     NS_QDFLUSHMANAGER_CONTRACTID,
00175     nsQDFlushManagerConstructor },
00176 #endif
00177 };
00178 
00179 PR_STATIC_CALLBACK(void)
00180 nsGfxMacModuleDtor(nsIModule *self)
00181 {
00182   nsUnicodeMappingUtil::FreeSingleton();
00183 }
00184 
00185 NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxMacModule, components, nsGfxMacModuleDtor)
00186 
00187