1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* 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 NPL, 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 NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#ifndef nsRenderingContextMac_h___
40
#define nsRenderingContextMac_h___
42
#include <QDOffscreen.h>
43
#include <UnicodeConverter.h>
45
#include "nsRenderingContextImpl.h"
46
#include "nsDrawingSurfaceMac.h"
47
#include "nsUnicodeRenderingToolkit.h"
49
#include "nsVoidArray.h"
52
class nsIDeviceContext;
58
class nsUnicodeFallbackCache;
60
//------------------------------------------------------------------------
63
class nsRenderingContextMac : public nsRenderingContextImpl
66
nsRenderingContextMac();
67
~nsRenderingContextMac();
69
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
73
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
74
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
76
NS_IMETHOD Reset(void);
77
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
78
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
79
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
81
NS_IMETHOD UnlockDrawingSurface(void);
82
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
83
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
84
NS_IMETHOD GetHints(PRUint32& aResult);
85
NS_IMETHOD PushState(void);
86
NS_IMETHOD PopState(PRBool &aClipEmpty);
87
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
88
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
89
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
90
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
91
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
92
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
93
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
94
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
95
NS_IMETHOD SetColor(nscolor aColor);
96
NS_IMETHOD GetColor(nscolor &aColor) const;
97
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
98
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
99
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
100
NS_IMETHOD Translate(nscoord aX, nscoord aY);
101
NS_IMETHOD Scale(float aSx, float aSy);
102
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
103
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
104
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
105
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
106
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
107
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
108
NS_IMETHOD DrawRect(const nsRect& aRect);
109
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
110
NS_IMETHOD FillRect(const nsRect& aRect);
111
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
112
NS_IMETHOD InvertRect(const nsRect& aRect);
113
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
114
NS_IMETHOD FlushRect(const nsRect& aRect);
115
NS_IMETHOD FlushRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
116
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
117
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
118
NS_IMETHOD DrawEllipse(const nsRect& aRect);
119
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
120
NS_IMETHOD FillEllipse(const nsRect& aRect);
121
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
122
NS_IMETHOD DrawArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
123
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
124
NS_IMETHOD FillArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
125
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
126
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
127
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
129
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
131
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
132
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
133
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
135
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,nscoord aX, nscoord aY,const nscoord* aSpacing);
136
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY,
138
const nscoord* aSpacing);
139
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
141
const nscoord* aSpacing);
143
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
144
nsTextDimensions& aDimensions);
145
NS_IMETHOD GetTextDimensions(const PRUnichar *aString, PRUint32 aLength,
146
nsTextDimensions& aDimensions, PRInt32 *aFontID);
148
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
149
const nsRect &aDestBounds, PRUint32 aCopyFlags);
150
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
152
// nsRenderingContextImpl overrides
153
NS_IMETHOD ReleaseBackbuffer(void);
154
NS_IMETHOD UseBackbuffer(PRBool* aUseBackbuffer);
159
* Returns metrics (in app units) of an 8-bit character string
161
NS_IMETHOD GetBoundingMetrics(const char* aString,
163
nsBoundingMetrics& aBoundingMetrics);
166
* Returns metrics (in app units) of a Unicode character string
168
NS_IMETHOD GetBoundingMetrics(const PRUnichar* aString,
170
nsBoundingMetrics& aBoundingMetrics,
172
#endif /* MOZ_MATHML */
174
* Let the device context know whether we want text reordered with
175
* right-to-left base direction
177
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
179
nsresult SetPortTextState();
180
nsresult Init(nsIDeviceContext* aContext, CGrafPtr aPort);
182
// useful for determining if we're running on MacOSX
183
static PRBool OnMacOSX();
184
static PRBool OnJaguar();
187
enum GraphicStateChanges {
188
kFontChanged = (1 << 0),
189
kColorChanged = (1 << 1),
190
kClippingChanged = (1 << 2),
192
kEverythingChanged = 0xFFFFFFFF
195
void SelectDrawingSurface(nsDrawingSurfaceMac* aSurface, PRUint32 aChanges = kEverythingChanged);
196
void SetupPortState();
199
float mP2T; // Pixel to Twip conversion factor
200
nsIDeviceContext * mContext;
202
nsDrawingSurfaceMac* mFrontSurface;
203
nsDrawingSurfaceMac* mCurrentSurface; // pointer to the current surface
205
CGrafPtr mPort; // current grafPort - shortcut for mCurrentSurface->GetPort()
206
nsGraphicState * mGS; // current graphic state - shortcut for mCurrentSurface->GetGS()
207
nsUnicodeRenderingToolkit mUnicodeRenderingToolkit;
208
nsAutoVoidArray mGSStack; // GraphicStates stack, used for PushState/PopState
209
PRUint32 mChanges; // bit mask of attributes that have changed since last Push().
210
PRBool mRightToLeftText;
213
#endif /* nsRenderingContextMac_h___ */