Back to index

lightning-sunbird  0.9+nobinonly
nsFontMetricsBeOS.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Paul Ashford <arougthopher@lizardland.net>
00024  *   Sergei Dolgov <sergei_d@fi.tartu.ee>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or 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 nsFontMetricsBeOS_h__
00041 #define nsFontMetricsBeOS_h__
00042 
00043 #include "nsDeviceContextBeOS.h" 
00044 #include "nsIFontMetrics.h" 
00045 #include "nsIFontEnumerator.h" 
00046 #include "nsFont.h"
00047 #include "nsString.h"
00048 #include "nsUnitConversion.h"
00049 #include "nsIDeviceContext.h"
00050 #include "nsCRT.h"
00051 #include "nsCOMPtr.h"
00052 #include "nsRenderingContextBeOS.h" 
00053 #include "nsICharRepresentable.h" 
00054 #include "nsDataHashtable.h"
00055 
00056 #include <Font.h>
00057 
00058 class nsFontMetricsBeOS : public nsIFontMetrics
00059 {
00060 public:
00061   nsFontMetricsBeOS();
00062   virtual ~nsFontMetricsBeOS();
00063 
00064   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
00065 
00066   NS_DECL_ISUPPORTS
00067 
00068   NS_IMETHOD  Init(const nsFont& aFont, nsIAtom* aLangGroup,
00069                    nsIDeviceContext* aContext);
00070   NS_IMETHOD  Destroy();
00071 
00072   NS_IMETHOD  GetXHeight(nscoord& aResult);
00073   NS_IMETHOD  GetSuperscriptOffset(nscoord& aResult);
00074   NS_IMETHOD  GetSubscriptOffset(nscoord& aResult);
00075   NS_IMETHOD  GetStrikeout(nscoord& aOffset, nscoord& aSize);
00076   NS_IMETHOD  GetUnderline(nscoord& aOffset, nscoord& aSize);
00077 
00078   NS_IMETHOD  GetHeight(nscoord &aHeight);
00079   NS_IMETHOD  GetNormalLineHeight(nscoord &aHeight); 
00080   NS_IMETHOD  GetLeading(nscoord &aLeading); 
00081   NS_IMETHOD  GetEmHeight(nscoord &aHeight); 
00082   NS_IMETHOD  GetEmAscent(nscoord &aAscent); 
00083   NS_IMETHOD  GetEmDescent(nscoord &aDescent); 
00084   NS_IMETHOD  GetMaxHeight(nscoord &aHeight); 
00085   NS_IMETHOD  GetMaxAscent(nscoord &aAscent);
00086   NS_IMETHOD  GetMaxDescent(nscoord &aDescent);
00087   NS_IMETHOD  GetMaxAdvance(nscoord &aAdvance);
00088   NS_IMETHOD  GetAveCharWidth(nscoord &aAveCharWidth);
00089   NS_IMETHOD  GetLangGroup(nsIAtom** aLangGroup);
00090   NS_IMETHOD  GetFontHandle(nsFontHandle &aHandle);
00091 
00092   NS_IMETHOD  GetSpaceWidth(nscoord &aSpaceWidth); 
00093  
00094   static nsresult FamilyExists(const nsString& aFontName);
00095   inline PRBool   IsBold() { return mIsBold; } 
00096   static int FontMatchesGenericType(font_family family, uint32 flags, const char* aGeneric,  const char* aLangGroup);
00097   nsCOMPtr<nsIAtom>   mLangGroup; 
00098   static int MatchesLangGroup(font_family family,  const char* aLangGroup);
00099   float GetStringWidth(char *string, uint32 len);
00100 
00101 protected:
00102   void RealizeFont(nsIDeviceContext* aContext);
00103 
00104   nsIDeviceContext    *mDeviceContext;
00105   BFont               mFontHandle;
00106 
00107   nscoord             mLeading;
00108   nscoord             mEmHeight; 
00109   nscoord             mEmAscent; 
00110   nscoord             mEmDescent; 
00111   nscoord             mMaxHeight; 
00112   nscoord             mMaxAscent;
00113   nscoord             mMaxDescent;
00114   nscoord             mMaxAdvance;
00115   nscoord             mAveCharWidth;
00116   nscoord             mXHeight;
00117   nscoord             mSuperscriptOffset;
00118   nscoord             mSubscriptOffset;
00119   nscoord             mStrikeoutSize;
00120   nscoord             mStrikeoutOffset;
00121   nscoord             mUnderlineSize;
00122   nscoord             mUnderlineOffset;
00123   nscoord             mSpaceWidth; 
00124  
00125   PRUint16            mPixelSize; 
00126   PRUint8             mStretchIndex; 
00127   PRUint8             mStyleIndex;
00128   PRBool              mIsBold;
00129   nsDataHashtable<nsUint32HashKey, float>         mFontWidthCache; 
00130 }; 
00131  
00132 class nsFontEnumeratorBeOS : public nsIFontEnumerator 
00133 { 
00134 public: 
00135   nsFontEnumeratorBeOS(); 
00136   NS_DECL_ISUPPORTS 
00137   NS_DECL_NSIFONTENUMERATOR 
00138 };
00139 
00140 #endif