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"
50
class nsRenderingContextImpl : public nsIRenderingContext
56
nsRenderingContextImpl();
62
* Return the maximum length of a string that can be handled by the platform
63
* using the current font metrics.
64
* The implementation here is just a stub; classes that don't override
65
* the safe string methods need to implement this.
67
virtual PRInt32 GetMaxStringLength() = 0;
70
* Let the device context know whether we want text reordered with
71
* right-to-left base direction
73
NS_IMETHOD GetRightToLeftText(PRBool* aIsRTL);
75
// Safe string method variants: by default, these defer to the more
76
// elaborate methods below
77
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
78
PRInt32 *aFontID = nsnull);
79
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
80
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
82
const nscoord* aSpacing = nsnull);
84
// Safe string methods
85
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
87
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
88
nscoord &aWidth, PRInt32 *aFontID = nsnull);
90
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
91
nsTextDimensions& aDimensions);
92
NS_IMETHOD GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
93
nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull);
95
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
96
NS_IMETHOD GetTextDimensions(const char* aString,
101
nsTextDimensions& aDimensions,
102
PRInt32& aNumCharsFit,
103
nsTextDimensions& aLastWordDimensions,
104
PRInt32* aFontID = nsnull);
106
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
111
nsTextDimensions& aDimensions,
112
PRInt32& aNumCharsFit,
113
nsTextDimensions& aLastWordDimensions,
114
PRInt32* aFontID = nsnull);
118
GetBoundingMetrics(const char* aString,
120
nsBoundingMetrics& aBoundingMetrics);
122
GetBoundingMetrics(const PRUnichar* aString,
124
nsBoundingMetrics& aBoundingMetrics,
125
PRInt32* aFontID = nsnull);
127
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
128
nscoord aX, nscoord aY,
129
const nscoord* aSpacing = nsnull);
130
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
131
nscoord aX, nscoord aY,
132
PRInt32 aFontID = -1,
133
const nscoord* aSpacing = nsnull);
135
// Unsafe platform-specific implementations
136
NS_IMETHOD GetWidthInternal(const char* aString, PRUint32 aLength,
138
{ return NS_ERROR_NOT_IMPLEMENTED; }
139
NS_IMETHOD GetWidthInternal(const PRUnichar *aString, PRUint32 aLength,
140
nscoord &aWidth, PRInt32 *aFontID = nsnull)
141
{ return NS_ERROR_NOT_IMPLEMENTED; }
143
NS_IMETHOD GetTextDimensionsInternal(const char* aString, PRUint32 aLength,
144
nsTextDimensions& aDimensions)
145
{ return NS_ERROR_NOT_IMPLEMENTED; }
146
NS_IMETHOD GetTextDimensionsInternal(const PRUnichar* aString, PRUint32 aLength,
147
nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull)
148
{ return NS_ERROR_NOT_IMPLEMENTED; }
150
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_BEOS)
151
NS_IMETHOD GetTextDimensionsInternal(const char* aString,
156
nsTextDimensions& aDimensions,
157
PRInt32& aNumCharsFit,
158
nsTextDimensions& aLastWordDimensions,
159
PRInt32* aFontID = nsnull)
160
{ return NS_ERROR_NOT_IMPLEMENTED; }
162
NS_IMETHOD GetTextDimensionsInternal(const PRUnichar* aString,
167
nsTextDimensions& aDimensions,
168
PRInt32& aNumCharsFit,
169
nsTextDimensions& aLastWordDimensions,
170
PRInt32* aFontID = nsnull)
171
{ return NS_ERROR_NOT_IMPLEMENTED; }
175
GetBoundingMetricsInternal(const char* aString,
177
nsBoundingMetrics& aBoundingMetrics)
178
{ return NS_ERROR_NOT_IMPLEMENTED; }
180
GetBoundingMetricsInternal(const PRUnichar* aString,
182
nsBoundingMetrics& aBoundingMetrics,
183
PRInt32* aFontID = nsnull)
184
{ return NS_ERROR_NOT_IMPLEMENTED; }
186
NS_IMETHOD DrawStringInternal(const char *aString, PRUint32 aLength,
187
nscoord aX, nscoord aY,
188
const nscoord* aSpacing = nsnull)
189
{ return NS_ERROR_NOT_IMPLEMENTED; }
190
NS_IMETHOD DrawStringInternal(const PRUnichar *aString, PRUint32 aLength,
191
nscoord aX, nscoord aY,
192
PRInt32 aFontID = -1,
193
const nscoord* aSpacing = nsnull)
194
{ return NS_ERROR_NOT_IMPLEMENTED; }
196
gfxContext *ThebesContext() { return nsnull; }
199
virtual ~nsRenderingContextImpl();
203
#endif /* nsRenderingContextImpl */