Back to index

lightning-sunbird  0.9+nobinonly
nsIFontMetricsGTK.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* vim:expandtab:shiftwidth=4:tabstop=4:
00003  */
00004 /* ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Christopher Blizzard <blizzard@mozilla.org>.  
00021  * Portions created by the Initial Developer are Copyright (C) 2002
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef __nsIFontMetricsGTK_h
00041 #define __nsIFontMetricsGTK_h
00042 
00043 #include "nsIFontMetrics.h"
00044 #include "nsIRenderingContext.h"
00045 
00046 #include "nsDrawingSurfaceGTK.h"
00047 
00048 class nsRenderingContextGTK;
00049 
00050 class nsIFontMetricsGTK : public nsIFontMetrics {
00051 public:
00052     // Get the width for this string.  aWidth will be updated with the
00053     // width in points, not twips.  Callers must convert it if they
00054     // want it in another format.
00055     virtual nsresult GetWidth(const char* aString, PRUint32 aLength,
00056                               nscoord& aWidth,
00057                               nsRenderingContextGTK *aContext) = 0;
00058     // aCachedOffset will be updated with a new offset.
00059     virtual nsresult GetWidth(const PRUnichar* aString, PRUint32 aLength,
00060                               nscoord& aWidth, PRInt32 *aFontID,
00061                               nsRenderingContextGTK *aContext) = 0;
00062 
00063     // Get the text dimensions for this string
00064     virtual nsresult GetTextDimensions(const PRUnichar* aString,
00065                                        PRUint32 aLength,
00066                                        nsTextDimensions& aDimensions, 
00067                                        PRInt32* aFontID,
00068                                        nsRenderingContextGTK *aContext) = 0;
00069     virtual nsresult GetTextDimensions(const char*         aString,
00070                                        PRInt32             aLength,
00071                                        PRInt32             aAvailWidth,
00072                                        PRInt32*            aBreaks,
00073                                        PRInt32             aNumBreaks,
00074                                        nsTextDimensions&   aDimensions,
00075                                        PRInt32&            aNumCharsFit,
00076                                        nsTextDimensions&   aLastWordDimensions,
00077                                        PRInt32*            aFontID,
00078                                        nsRenderingContextGTK *aContext)=0;
00079     virtual nsresult GetTextDimensions(const PRUnichar*    aString,
00080                                        PRInt32             aLength,
00081                                        PRInt32             aAvailWidth,
00082                                        PRInt32*            aBreaks,
00083                                        PRInt32             aNumBreaks,
00084                                        nsTextDimensions&   aDimensions,
00085                                        PRInt32&            aNumCharsFit,
00086                                        nsTextDimensions&   aLastWordDimensions,
00087                                        PRInt32*            aFontID,
00088                                        nsRenderingContextGTK *aContext)=0;
00089 
00090     // Draw a string using this font handle on the surface passed in.  
00091     virtual nsresult DrawString(const char *aString, PRUint32 aLength,
00092                                 nscoord aX, nscoord aY,
00093                                 const nscoord* aSpacing,
00094                                 nsRenderingContextGTK *aContext,
00095                                 nsDrawingSurfaceGTK *aSurface) = 0;
00096     // aCachedOffset will be updated with a new offset.
00097     virtual nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
00098                                 nscoord aX, nscoord aY,
00099                                 PRInt32 aFontID,
00100                                 const nscoord* aSpacing,
00101                                 nsRenderingContextGTK *aContext,
00102                                 nsDrawingSurfaceGTK *aSurface) = 0;
00103 
00104 #ifdef MOZ_MATHML
00105     // These two functions get the bounding metrics for this handle,
00106     // updating the aBoundingMetrics in Points.  This means that the
00107     // caller will have to update them to twips before passing it
00108     // back.
00109     virtual nsresult GetBoundingMetrics(const char *aString, PRUint32 aLength,
00110                                         nsBoundingMetrics &aBoundingMetrics,
00111                                         nsRenderingContextGTK *aContext) = 0;
00112     // aCachedOffset will be updated with a new offset.
00113     virtual nsresult GetBoundingMetrics(const PRUnichar *aString,
00114                                         PRUint32 aLength,
00115                                         nsBoundingMetrics &aBoundingMetrics,
00116                                         PRInt32 *aFontID,
00117                                         nsRenderingContextGTK *aContext) = 0;
00118 #endif /* MOZ_MATHML */
00119 
00120     // Get a GdkFont for this handle, if there is one.  This can
00121     // return 0, which means there is no GdkFont associated with this
00122     // particular handle.
00123     virtual GdkFont* GetCurrentGDKFont(void) = 0;
00124 
00125     // Set the direction of the text rendering
00126     virtual nsresult SetRightToLeftText(PRBool aIsRTL) = 0;
00127     virtual PRBool GetRightToLeftText() = 0;
00128 
00129     virtual nsresult GetClusterInfo(const PRUnichar *aText,
00130                                     PRUint32 aLength,
00131                                     PRUint8 *aClusterStarts) = 0;
00132 
00133     virtual PRInt32 GetPosition(const PRUnichar *aText,
00134                                 PRUint32 aLength,
00135                                 nsPoint aPt) = 0;
00136 
00137     virtual nsresult GetRangeWidth(const PRUnichar *aText,
00138                                    PRUint32 aLength,
00139                                    PRUint32 aStart,
00140                                    PRUint32 aEnd,
00141                                    PRUint32 &aWidth) = 0;
00142     virtual nsresult GetRangeWidth(const char *aText,
00143                                    PRUint32 aLength,
00144                                    PRUint32 aStart,
00145                                    PRUint32 aEnd,
00146                                    PRUint32 &aWidth) = 0;
00147     virtual PRInt32 GetMaxStringLength() = 0;
00148 };
00149 
00150 #endif /* __nsIFontMetricsGTK_h */