Back to index

lightning-sunbird  0.9+nobinonly
nsGfxFactoryBeOS.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  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsIGenericFactory.h" 
00039 #include "nsIModule.h" 
00040 #include "nsCOMPtr.h" 
00041 #include "nsGfxCIID.h" 
00042  
00043 #include "nsBlender.h" 
00044 #include "nsFontMetricsBeOS.h"
00045 #include "nsRenderingContextBeOS.h"
00046 // aka    nsDeviceContextSpecBeOS.h 
00047 #include "nsDeviceContextSpecB.h"
00048 // aka    nsDeviceContextSpecFactoryBeOS.h
00049 #include "nsDeviceContextSpecFactoryB.h" 
00050 #include "nsScreenManagerBeOS.h" 
00051 #include "nsScriptableRegion.h" 
00052 #include "nsDeviceContextBeOS.h" 
00053 #include "nsPrintOptionsBeOS.h"
00054 #include "nsImageBeOS.h" 
00055 #include "nsFontList.h"
00056 #include "nsPrintSession.h"
00057 #include "gfxImageFrame.h"
00058 
00059 // objects that just require generic constructors 
00060 
00061 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsBeOS) 
00062 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextBeOS) 
00063 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextBeOS) 
00064 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageBeOS) 
00065 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender) 
00066 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionBeOS) 
00067 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecBeOS) 
00068 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryBeOS) 
00069 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorBeOS) 
00070 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
00071 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerBeOS) 
00072 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorBeOS) 
00073 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsBeOS, Init)
00074 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
00075 NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
00076  
00077 // our custom constructors 
00078  
00079 static NS_IMETHODIMP nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) 
00080 { 
00081   nsresult rv; 
00082  
00083   nsIScriptableRegion *inst; 
00084  
00085   if ( !aResult ) 
00086   { 
00087     rv = NS_ERROR_NULL_POINTER; 
00088     return rv; 
00089   } 
00090   *aResult = nsnull; 
00091   if (aOuter) 
00092   { 
00093     rv = NS_ERROR_NO_AGGREGATION; 
00094     return rv; 
00095   } 
00096   // create an nsRegionBeOS and get the scriptable region from it 
00097   nsCOMPtr <nsIRegion> rgn; 
00098   NS_NEWXPCOM(rgn, nsRegionBeOS); 
00099   nsCOMPtr<nsIScriptableRegion> scriptableRgn;
00100   if (rgn != nsnull) 
00101   { 
00102     scriptableRgn = new nsScriptableRegion(rgn); 
00103     inst = scriptableRgn; 
00104   } 
00105   if (!inst) 
00106   { 
00107     rv = NS_ERROR_OUT_OF_MEMORY; 
00108     return rv; 
00109   } 
00110   NS_ADDREF(inst); 
00111   // release our variable above now that we have created our owning
00112   // reference - we don't want this to go out of scope early!
00113   scriptableRgn = nsnull;
00114   rv = inst->QueryInterface(aIID, aResult); 
00115   NS_RELEASE(inst); 
00116  
00117   return rv; 
00118 } 
00119  
00120 static const nsModuleComponentInfo components[] = 
00121 { 
00122   { "BeOS Font Metrics", 
00123     NS_FONT_METRICS_CID, 
00124     //    "@mozilla.org/gfx/font_metrics/beos;1", 
00125     "@mozilla.org/gfx/fontmetrics;1", 
00126     nsFontMetricsBeOSConstructor }, 
00127   { "BeOS Device Context", 
00128     NS_DEVICE_CONTEXT_CID, 
00129     //    "@mozilla.org/gfx/device_context/beos;1", 
00130     "@mozilla.org/gfx/devicecontext;1", 
00131     nsDeviceContextBeOSConstructor }, 
00132   { "BeOS Rendering Context", 
00133     NS_RENDERING_CONTEXT_CID, 
00134     //    "@mozilla.org/gfx/rendering_context/beos;1", 
00135     "@mozilla.org/gfx/renderingcontext;1", 
00136     nsRenderingContextBeOSConstructor }, 
00137   { "BeOS Image", 
00138     NS_IMAGE_CID, 
00139     //    "@mozilla.org/gfx/image/beos;1", 
00140     "@mozilla.org/gfx/image;1", 
00141     nsImageBeOSConstructor }, 
00142   { "BeOS Region", 
00143     NS_REGION_CID, 
00144     "@mozilla.org/gfx/region/beos;1", 
00145     nsRegionBeOSConstructor }, 
00146   { "Scriptable Region", 
00147     NS_SCRIPTABLE_REGION_CID, 
00148     //    "@mozilla.org/gfx/scriptable_region;1", 
00149     "@mozilla.org/gfx/region;1", 
00150     nsScriptableRegionConstructor }, 
00151   { "Blender", 
00152     NS_BLENDER_CID, 
00153     //    "@mozilla.org/gfx/blender;1", 
00154     "@mozilla.org/gfx/blender;1", 
00155     nsBlenderConstructor }, 
00156   { "BeOS Device Context Spec", 
00157     NS_DEVICE_CONTEXT_SPEC_CID, 
00158     //    "@mozilla.org/gfx/device_context_spec/beos;1", 
00159     "@mozilla.org/gfx/devicecontextspec;1", 
00160     nsDeviceContextSpecBeOSConstructor }, 
00161   { "BeOS Device Context Spec Factory", 
00162     NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, 
00163     //    "@mozilla.org/gfx/device_context_spec_factory/beos;1", 
00164     "@mozilla.org/gfx/devicecontextspecfactory;1", 
00165     nsDeviceContextSpecFactoryBeOSConstructor }, 
00166   { "BeOS Font Enumerator", 
00167     NS_FONT_ENUMERATOR_CID, 
00168     //    "@mozilla.org/gfx/font_enumerator/beos;1", 
00169     "@mozilla.org/gfx/fontenumerator;1", 
00170     nsFontEnumeratorBeOSConstructor }, 
00171   { "Font List",  
00172     NS_FONTLIST_CID,
00173     //    "@mozilla.org/gfx/fontlist;1"
00174     NS_FONTLIST_CONTRACTID,
00175     nsFontListConstructor },
00176   { "BeOS Screen Manager", 
00177     NS_SCREENMANAGER_CID, 
00178     //    "@mozilla.org/gfx/screenmanager/beos;1", 
00179     "@mozilla.org/gfx/screenmanager;1", 
00180     nsScreenManagerBeOSConstructor },
00181   { "BeOS Printer Enumerator",
00182     NS_PRINTER_ENUMERATOR_CID,
00183     //    "@mozilla.org/gfx/printer_enumerator/beos;1",
00184     "@mozilla.org/gfx/printerenumerator;1",
00185     nsPrinterEnumeratorBeOSConstructor },
00186   { "BeOS PrintSettings Service",
00187        NS_PRINTSETTINGSSERVICE_CID,
00188        "@mozilla.org/gfx/printsettings-service;1",
00189        nsPrintOptionsBeOSConstructor },
00190   { "Print Session",
00191     NS_PRINTSESSION_CID,
00192     "@mozilla.org/gfx/printsession;1",
00193     nsPrintSessionConstructor },
00194   { "windows image frame",
00195     GFX_IMAGEFRAME_CID,
00196     "@mozilla.org/gfx/image/frame;2",
00197     gfxImageFrameConstructor, },
00198 };   
00199 
00200 NS_IMPL_NSGETMODULE(nsGfxBeOSModule, components)