Back to index

lightning-sunbird  0.9+nobinonly
nsDeviceContextOS2.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  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsDeviceContextOS2_h___
00039 #define nsDeviceContextOS2_h___
00040 
00041 #include "nsGfxDefs.h"
00042 
00043 #include "nsDeviceContext.h"
00044 #include "nsIScreenManager.h"
00045 #include "nsDeviceContextSpecOS2.h"
00046 
00047 class nsIScreen;
00048 
00049 class nsDeviceContextOS2 : public DeviceContextImpl
00050 {
00051 public:
00052   nsDeviceContextOS2();
00053 
00054   NS_IMETHOD  Init(nsNativeWidget aWidget);
00055 
00056   using DeviceContextImpl::CreateRenderingContext;
00057   NS_IMETHOD  CreateRenderingContext(nsIRenderingContext *&aContext);
00058 
00059   NS_IMETHOD  SupportsNativeWidgets(PRBool &aSupportsWidgets);
00060 
00061   NS_IMETHOD  GetScrollBarDimensions(float &aWidth, float &aHeight) const;
00062   NS_IMETHOD  GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
00063 
00064   NS_IMETHOD  CheckFontExistence(const nsString& aFontName);
00065 
00066   NS_IMETHOD  GetDepth(PRUint32& aDepth);
00067 
00068   NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
00069   NS_IMETHOD GetRect(nsRect &aRect);
00070   NS_IMETHOD GetClientRect(nsRect &aRect);
00071 
00072   NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
00073                                  nsIDeviceContext *&aContext);
00074 
00075   NS_IMETHOD PrepareDocument(PRUnichar * aTitle, 
00076                              PRUnichar*  aPrintToFileName);
00077   NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
00078   NS_IMETHOD EndDocument(void);
00079   NS_IMETHOD AbortDocument(void);
00080 
00081   NS_IMETHOD BeginPage(void);
00082   NS_IMETHOD EndPage(void);
00083 
00084   // Static Helper Methods
00085   static char* GetACPString(const nsString& aStr);
00086   nsresult   SetDPI(PRInt32 aPrefDPI);
00087   int        GetDPI() { return mDpi; };
00088 
00089 protected:
00090   virtual ~nsDeviceContextOS2();
00091   void CommonInit(HDC aDC);
00092   nsresult Init(nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext);
00093   void FindScreen ( nsIScreen** outScreen ) ;
00094   void ComputeClientRectUsingScreen ( nsRect* outRect ) ;
00095   void ComputeFullAreaUsingScreen ( nsRect* outRect ) ;
00096 
00097   PRBool mCachedClientRect;
00098   PRBool mCachedFullRect;
00099   PRBool mPrintingStarted;
00100 
00101   nsIDrawingSurface*      mSurface;
00102   PRUint32              mDepth;  // bit depth of device
00103   PRBool                mIsPaletteDevice;
00104   PRInt32               mWidth;
00105   PRInt32               mHeight;
00106   nsRect                mClientRect;
00107   nsIDeviceContextSpec  *mSpec;
00108   PRBool                mSupportsRasterFonts;
00109 
00110   nsCOMPtr<nsIScreenManager> mScreenManager;
00111   static PRUint32 sNumberOfScreens;
00112   static nscoord mDpi;
00113 
00114 public:
00115   HDC                   mPrintDC;
00116   HPS                   mPrintPS;
00117 
00118   enum nsPrintState
00119   {
00120      nsPrintState_ePreBeginDoc,
00121      nsPrintState_eBegunDoc,
00122      nsPrintState_eBegunFirstPage,
00123      nsPrintState_eEndedDoc
00124   } mPrintState;
00125 
00126   BOOL isPrintDC();
00127   PRBool SupportsRasterFonts();
00128   PRBool IsPaletteDevice() {return mIsPaletteDevice;};
00129   nsresult CreateFontAliasTable();
00130 };
00131 
00132 int PR_CALLBACK prefChanged(const char *aPref, void *aClosure);
00133 
00134 #endif /* nsDeviceContextOS2_h___ */