Back to index

lightning-sunbird  0.9+nobinonly
nsGfxFactoryXlib.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  *   Peter Hartshorn <peter@igelaus.com.au>
00024  *   Tony Tsui <tony@igelaus.com.au>
00025  *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "nsIGenericFactory.h"
00042 #include "nsIModule.h"
00043 #include "nsCOMPtr.h"
00044 #include "nsGfxCIID.h"
00045 
00046 #include "nsBlender.h"
00047 #include "nsFontMetricsXlib.h"
00048 #include "nsRenderingContextXlib.h"
00049 // aka    nsDeviceContextSpecXlib.h
00050 #include "nsDeviceContextSpecXlib.h"
00051 // aka    nsDeviceContextSpecFactoryXlib.h
00052 #include "nsDeviceContextSpecFactoryX.h"
00053 #include "nsScreenManagerXlib.h"
00054 #include "nsScriptableRegion.h"
00055 #include "nsDeviceContextXlib.h"
00056 #include "nsImageXlib.h"
00057 #include "nsFontList.h"
00058 #include "nsPrintOptionsXlib.h"
00059 #include "nsPrintSession.h"
00060 #include "gfxImageFrame.h"
00061 
00062 // objects that just require generic constructors
00063 
00064 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsXlib)
00065 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextXlib)
00066 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextXlib)
00067 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageXlib)
00068 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
00069 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionXlib)
00070 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecXlib)
00071 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryXlib)
00072 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorXlib)
00073 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
00074 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerXlib)
00075 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsXlib, Init)
00076 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorXlib)
00077 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
00078 NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
00079 
00080 // our custom constructors
00081 
00082 static nsresult nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00083 {
00084   nsresult rv;
00085 
00086   nsIScriptableRegion *inst = nsnull;
00087 
00088   if ( NULL == aResult )
00089   {
00090     rv = NS_ERROR_NULL_POINTER;
00091     return rv;
00092   }
00093   *aResult = NULL;
00094   if (NULL != aOuter)
00095   {
00096     rv = NS_ERROR_NO_AGGREGATION;
00097     return rv;
00098   }
00099   // create an nsRegionXlib and get the scriptable region from it
00100   nsCOMPtr <nsIRegion> rgn;
00101   NS_NEWXPCOM(rgn, nsRegionXlib);
00102   if (rgn != nsnull)
00103   {
00104     nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
00105     inst = scriptableRgn;
00106   }
00107   if (NULL == inst)
00108   {
00109     rv = NS_ERROR_OUT_OF_MEMORY;
00110     return rv;
00111   }
00112   NS_ADDREF(inst);
00113   rv = inst->QueryInterface(aIID, aResult);
00114   NS_RELEASE(inst);
00115 
00116   return rv;
00117 }
00118 
00119 static const nsModuleComponentInfo components[] =
00120 {
00121   { "Xlib Font Metrics",
00122     NS_FONT_METRICS_CID,
00123     //    "@mozilla.org/gfx/font_metrics/xlib;1",
00124     "@mozilla.org/gfx/fontmetrics;1",
00125     nsFontMetricsXlibConstructor },
00126   { "Xlib Device Context",
00127     NS_DEVICE_CONTEXT_CID,
00128     //    "@mozilla.org/gfx/device_context/xlib;1",
00129     "@mozilla.org/gfx/devicecontext;1",
00130     nsDeviceContextXlibConstructor },
00131   { "Xlib Rendering Context",
00132     NS_RENDERING_CONTEXT_CID,
00133     //    "@mozilla.org/gfx/rendering_context/xlib;1",
00134     "@mozilla.org/gfx/renderingcontext;1",
00135     nsRenderingContextXlibConstructor },
00136   { "Xlib Image",
00137     NS_IMAGE_CID,
00138     //    "@mozilla.org/gfx/image/xlib;1",
00139     "@mozilla.org/gfx/image;1",
00140     nsImageXlibConstructor },
00141   { "Xlib Region",
00142     NS_REGION_CID,
00143     "@mozilla.org/gfx/region/xlib;1",
00144     nsRegionXlibConstructor },
00145   { "Scriptable Region",
00146     NS_SCRIPTABLE_REGION_CID,
00147     //    "@mozilla.org/gfx/scriptable_region;1",
00148     "@mozilla.org/gfx/region;1",
00149     nsScriptableRegionConstructor },
00150   { "Blender",
00151     NS_BLENDER_CID,
00152     //    "@mozilla.org/gfx/blender;1",
00153     "@mozilla.org/gfx/blender;1",
00154     nsBlenderConstructor },
00155   { "Xlib Device Context Spec",
00156     NS_DEVICE_CONTEXT_SPEC_CID,
00157     //    "@mozilla.org/gfx/device_context_spec/xlib;1",
00158     "@mozilla.org/gfx/devicecontextspec;1",
00159     nsDeviceContextSpecXlibConstructor },
00160   { "Xlib Device Context Spec Factory",
00161     NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
00162     //    "@mozilla.org/gfx/device_context_spec_factory/xlib;1",
00163     "@mozilla.org/gfx/devicecontextspecfactory;1",
00164     nsDeviceContextSpecFactoryXlibConstructor },
00165   { "PrintSettings Service",
00166      NS_PRINTSETTINGSSERVICE_CID,
00167      //    "@mozilla.org/gfx/printsettings-service;1",
00168      "@mozilla.org/gfx/printsettings-service;1",
00169      nsPrintOptionsXlibConstructor },      
00170   { "Xlib Font Enumerator",
00171     NS_FONT_ENUMERATOR_CID,
00172     //    "@mozilla.org/gfx/font_enumerator/xlib;1",
00173     "@mozilla.org/gfx/fontenumerator;1",
00174       nsFontEnumeratorXlibConstructor },
00175   { "Font List",  
00176     NS_FONTLIST_CID,
00177     //    "@mozilla.org/gfx/fontlist;1"
00178     NS_FONTLIST_CONTRACTID,
00179     nsFontListConstructor },
00180   { "Xlib Screen Manager",
00181     NS_SCREENMANAGER_CID,
00182     //    "@mozilla.org/gfx/screenmanager/xlib;1",
00183     "@mozilla.org/gfx/screenmanager;1",
00184     nsScreenManagerXlibConstructor },
00185   { "Xlib Printer Enumerator",
00186     NS_PRINTER_ENUMERATOR_CID,
00187     //    "@mozilla.org/gfx/printer_enumerator/xlib;1",
00188     "@mozilla.org/gfx/printerenumerator;1",
00189     nsPrinterEnumeratorXlibConstructor },
00190   { "windows image frame",
00191     GFX_IMAGEFRAME_CID,
00192     "@mozilla.org/gfx/image/frame;2",
00193     gfxImageFrameConstructor, },
00194   { "Print Session",
00195     NS_PRINTSESSION_CID,
00196     "@mozilla.org/gfx/printsession;1",
00197     nsPrintSessionConstructor }
00198 };
00199 
00200 PR_STATIC_CALLBACK(void)
00201 nsGfxXlibModuleDtor(nsIModule *self)
00202 {
00203 }
00204 
00205 NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxXlibModule, components, nsGfxXlibModuleDtor)