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.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsRenderingContextImpl_h___
39 #define nsRenderingContextImpl_h___
42 #include "nsIRenderingContext.h"
48 class nsRenderingContextImpl
: public nsIRenderingContext
54 nsRenderingContextImpl();
60 * Return the maximum length of a string that can be handled by the platform
61 * using the current font metrics.
62 * The implementation here is just a stub; classes that don't override
63 * the safe string methods need to implement this.
65 virtual PRInt32
GetMaxStringLength() = 0;
68 * Let the device context know whether we want text reordered with
69 * right-to-left base direction
71 NS_IMETHOD
GetRightToLeftText(PRBool
* aIsRTL
);
73 // Safe string method variants: by default, these defer to the more
74 // elaborate methods below
75 NS_IMETHOD
GetWidth(const nsString
& aString
, nscoord
&aWidth
,
76 PRInt32
*aFontID
= nsnull
);
77 NS_IMETHOD
GetWidth(const char* aString
, nscoord
& aWidth
);
78 NS_IMETHOD
DrawString(const nsString
& aString
, nscoord aX
, nscoord aY
,
80 const nscoord
* aSpacing
= nsnull
);
82 // Safe string methods
83 NS_IMETHOD
GetWidth(const char* aString
, PRUint32 aLength
,
85 NS_IMETHOD
GetWidth(const PRUnichar
*aString
, PRUint32 aLength
,
86 nscoord
&aWidth
, PRInt32
*aFontID
= nsnull
);
88 NS_IMETHOD
GetTextDimensions(const char* aString
, PRUint32 aLength
,
89 nsTextDimensions
& aDimensions
);
90 NS_IMETHOD
GetTextDimensions(const PRUnichar
* aString
, PRUint32 aLength
,
91 nsTextDimensions
& aDimensions
, PRInt32
* aFontID
= nsnull
);
93 #if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
94 NS_IMETHOD
GetTextDimensions(const char* aString
,
99 nsTextDimensions
& aDimensions
,
100 PRInt32
& aNumCharsFit
,
101 nsTextDimensions
& aLastWordDimensions
,
102 PRInt32
* aFontID
= nsnull
);
104 NS_IMETHOD
GetTextDimensions(const PRUnichar
* aString
,
109 nsTextDimensions
& aDimensions
,
110 PRInt32
& aNumCharsFit
,
111 nsTextDimensions
& aLastWordDimensions
,
112 PRInt32
* aFontID
= nsnull
);
116 GetBoundingMetrics(const char* aString
,
118 nsBoundingMetrics
& aBoundingMetrics
);
120 GetBoundingMetrics(const PRUnichar
* aString
,
122 nsBoundingMetrics
& aBoundingMetrics
,
123 PRInt32
* aFontID
= nsnull
);
125 NS_IMETHOD
DrawString(const char *aString
, PRUint32 aLength
,
126 nscoord aX
, nscoord aY
,
127 const nscoord
* aSpacing
= nsnull
);
128 NS_IMETHOD
DrawString(const PRUnichar
*aString
, PRUint32 aLength
,
129 nscoord aX
, nscoord aY
,
130 PRInt32 aFontID
= -1,
131 const nscoord
* aSpacing
= nsnull
);
133 // Unsafe platform-specific implementations
134 NS_IMETHOD
GetWidthInternal(const char* aString
, PRUint32 aLength
,
136 { return NS_ERROR_NOT_IMPLEMENTED
; }
137 NS_IMETHOD
GetWidthInternal(const PRUnichar
*aString
, PRUint32 aLength
,
138 nscoord
&aWidth
, PRInt32
*aFontID
= nsnull
)
139 { return NS_ERROR_NOT_IMPLEMENTED
; }
141 NS_IMETHOD
GetTextDimensionsInternal(const char* aString
, PRUint32 aLength
,
142 nsTextDimensions
& aDimensions
)
143 { return NS_ERROR_NOT_IMPLEMENTED
; }
144 NS_IMETHOD
GetTextDimensionsInternal(const PRUnichar
* aString
, PRUint32 aLength
,
145 nsTextDimensions
& aDimensions
, PRInt32
* aFontID
= nsnull
)
146 { return NS_ERROR_NOT_IMPLEMENTED
; }
148 #if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
149 NS_IMETHOD
GetTextDimensionsInternal(const char* aString
,
154 nsTextDimensions
& aDimensions
,
155 PRInt32
& aNumCharsFit
,
156 nsTextDimensions
& aLastWordDimensions
,
157 PRInt32
* aFontID
= nsnull
)
158 { return NS_ERROR_NOT_IMPLEMENTED
; }
160 NS_IMETHOD
GetTextDimensionsInternal(const PRUnichar
* aString
,
165 nsTextDimensions
& aDimensions
,
166 PRInt32
& aNumCharsFit
,
167 nsTextDimensions
& aLastWordDimensions
,
168 PRInt32
* aFontID
= nsnull
)
169 { return NS_ERROR_NOT_IMPLEMENTED
; }
173 GetBoundingMetricsInternal(const char* aString
,
175 nsBoundingMetrics
& aBoundingMetrics
)
176 { return NS_ERROR_NOT_IMPLEMENTED
; }
178 GetBoundingMetricsInternal(const PRUnichar
* aString
,
180 nsBoundingMetrics
& aBoundingMetrics
,
181 PRInt32
* aFontID
= nsnull
)
182 { return NS_ERROR_NOT_IMPLEMENTED
; }
184 NS_IMETHOD
DrawStringInternal(const char *aString
, PRUint32 aLength
,
185 nscoord aX
, nscoord aY
,
186 const nscoord
* aSpacing
= nsnull
)
187 { return NS_ERROR_NOT_IMPLEMENTED
; }
188 NS_IMETHOD
DrawStringInternal(const PRUnichar
*aString
, PRUint32 aLength
,
189 nscoord aX
, nscoord aY
,
190 PRInt32 aFontID
= -1,
191 const nscoord
* aSpacing
= nsnull
)
192 { return NS_ERROR_NOT_IMPLEMENTED
; }
194 gfxContext
*ThebesContext() { return nsnull
; }
197 virtual ~nsRenderingContextImpl();
201 #endif /* nsRenderingContextImpl */