1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Roland Mainz <Roland.Mainz@informatik.med.uni-giessen.de>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef nsDeviceContext_h___
40 #define nsDeviceContext_h___
42 #include "nsIDeviceContext.h"
43 #include "nsIDeviceContextSpec.h"
46 #include "nsVoidArray.h"
47 #include "nsIObserver.h"
48 #include "nsIObserverService.h"
49 #include "nsWeakReference.h"
52 class nsIImageRequest
;
55 class NS_GFX nsFontCache
59 virtual ~nsFontCache();
61 virtual nsresult
Init(nsIDeviceContext
* aContext
);
62 virtual nsresult
GetDeviceContext(nsIDeviceContext
*&aContext
) const;
63 virtual nsresult
GetMetricsFor(const nsFont
& aFont
, nsIAtom
* aLangGroup
,
64 nsIFontMetrics
*&aMetrics
, gfxUserFontSet
*aUserFontSet
= nsnull
);
66 nsresult
FontMetricsDeleted(const nsIFontMetrics
* aFontMetrics
);
69 /* printer device context classes may create their own
70 * subclasses of nsFontCache (and override this method) and override
71 * DeviceContextImpl::CreateFontCache (see bug 81311).
73 virtual nsresult
CreateFontMetricsInstance(nsIFontMetrics
** fm
);
76 nsVoidArray mFontMetrics
;
77 nsIDeviceContext
*mContext
; // we do not addref this since
78 // ownership is implied. MMP.
81 // inherit visibility from the NS_GFX class declaration
82 #undef IMETHOD_VISIBILITY
83 #define IMETHOD_VISIBILITY
85 class NS_GFX DeviceContextImpl
: public nsIDeviceContext
,
87 public nsSupportsWeakReference
95 NS_IMETHOD
Init(nsNativeWidget aWidget
);
97 NS_IMETHOD
CreateRenderingContext(nsIView
*aView
, nsIRenderingContext
*&aContext
);
98 NS_IMETHOD
CreateRenderingContext(nsIWidget
*aWidget
, nsIRenderingContext
*&aContext
);
99 NS_IMETHOD
CreateRenderingContext(nsIRenderingContext
*&aContext
){return NS_ERROR_NOT_IMPLEMENTED
;}
100 NS_IMETHOD
CreateRenderingContextInstance(nsIRenderingContext
*&aContext
);
102 NS_IMETHOD
GetMetricsFor(const nsFont
& aFont
, nsIAtom
* aLangGroup
,
103 nsIFontMetrics
*& aMetrics
, gfxUserFontSet
*aUserFontSet
= nsnull
);
104 NS_IMETHOD
GetMetricsFor(const nsFont
& aFont
, nsIFontMetrics
*& aMetrics
,
105 gfxUserFontSet
*aUserFontSet
= nsnull
);
107 NS_IMETHOD
FirstExistingFont(const nsFont
& aFont
, nsString
& aFaceName
);
109 NS_IMETHOD
GetLocalFontName(const nsString
& aFaceName
, nsString
& aLocalName
,
112 NS_IMETHOD
CreateFontCache();
113 NS_IMETHOD
FontMetricsDeleted(const nsIFontMetrics
* aFontMetrics
);
114 NS_IMETHOD
FlushFontCache(void);
116 NS_IMETHOD
GetDepth(PRUint32
& aDepth
);
118 NS_IMETHOD
GetPaletteInfo(nsPaletteInfo
& aPaletteInfo
);
120 NS_IMETHOD
PrepareDocument(PRUnichar
* aTitle
,
121 PRUnichar
* aPrintToFileName
) { return NS_OK
; }
122 NS_IMETHOD
AbortDocument(void) { return NS_OK
; }
124 NS_IMETHOD
PrepareNativeWidget(nsIWidget
*aWidget
, void **aOut
);
125 NS_IMETHOD
ClearCachedSystemFonts();
128 /* Helper methods for |CreateRenderingContext|&co. */
129 nsresult
InitRenderingContext(nsIRenderingContext
*aContext
, nsIWidget
*aWindow
);
132 virtual ~DeviceContextImpl();
134 void CommonInit(void);
135 nsresult
CreateIconILGroupContext();
136 virtual nsresult
CreateFontAliasTable();
137 nsresult
AliasFont(const nsString
& aFont
,
138 const nsString
& aAlias
, const nsString
& aAltAlias
,
140 void GetLocaleLangGroup(void);
142 nsFontCache
*mFontCache
;
143 nsCOMPtr
<nsIAtom
> mLocaleLangGroup
; // XXX temp fix for performance bug - erik
144 nsHashtable
* mFontAliasTable
;
147 nsNativeWidget mWidget
;
153 #undef IMETHOD_VISIBILITY
154 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
156 #endif /* nsDeviceContext_h___ */