Back to index

lightning-sunbird  0.9+nobinonly
nsCairoDeviceContext.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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  * mozilla.org.
00019  * Portions created by the Initial Developer are Copyright (C) 2004
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Stuart Parmenter <pavlov@pavlov.net>
00024  *   Vladimir Vukicevic <vladimir@pobox.com>
00025  *   Joe Hewitt <hewitt@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #ifndef _NS_CAIRODEVICECONTEXT_H_
00042 #define _NS_CAIRODEVICECONTEXT_H_
00043 
00044 #include "nsIScreenManager.h"
00045 
00046 #include "nsDeviceContext.h"
00047 
00048 #include <cairo.h>
00049 #ifdef MOZ_X11
00050 #include <cairo-xlib.h>
00051 #endif
00052 
00053 #if defined(MOZ_ENABLE_GTK2) || defined(MOZ_ENABLE_XLIB)
00054 #include <X11/Xlib.h>
00055 #endif
00056 
00057 #ifdef MOZ_ENABLE_XLIB
00058 #include "xlibrgb.h"
00059 #endif
00060 
00061 class nsCairoDeviceContext : public DeviceContextImpl
00062 {
00063 public:
00064     nsCairoDeviceContext();
00065     virtual ~nsCairoDeviceContext();
00066 
00067     NS_DECL_ISUPPORTS_INHERITED
00068 
00069     NS_IMETHOD Init(nsNativeWidget aWidget);
00070     NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
00071 
00072     NS_IMETHOD CreateRenderingContext(nsIDrawingSurface *aSurface, nsIRenderingContext *&aContext);
00073     NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
00074     NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
00075     NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext);
00076 
00077     NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
00078 
00079     NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
00080 
00081     NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
00082 
00083     NS_IMETHOD CheckFontExistence(const nsString& aFaceName);
00084 
00085     NS_IMETHOD GetDepth(PRUint32& aDepth);
00086 
00087     NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo);
00088 
00089     NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
00090 
00091     NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
00092     NS_IMETHOD GetRect(nsRect &aRect);
00093     NS_IMETHOD GetClientRect(nsRect &aRect);
00094 
00095     NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
00096                                    nsIDeviceContext *&aContext);
00097 
00098     NS_IMETHOD PrepareDocument(PRUnichar * aTitle, 
00099                                PRUnichar*  aPrintToFileName);
00100 
00101     NS_IMETHOD BeginDocument(PRUnichar*  aTitle, 
00102                              PRUnichar*  aPrintToFileName,
00103                              PRInt32     aStartPage, 
00104                              PRInt32     aEndPage);
00105 
00106     NS_IMETHOD EndDocument(void);
00107     NS_IMETHOD AbortDocument(void);
00108     NS_IMETHOD BeginPage(void);
00109     NS_IMETHOD EndPage(void);
00110     NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC);
00111     NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC);
00112     NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn);
00113 
00114 #if defined(MOZ_ENABLE_GTK2) || defined(MOZ_ENABLE_XLIB)
00115     Display *GetXDisplay();
00116     Visual *GetXVisual();
00117     Colormap GetXColormap();
00118     Drawable GetXPixmapParentDrawable();
00119 #endif
00120 
00121 private:
00122     nsNativeWidget mWidget;
00123 
00124     nsCOMPtr<nsIScreenManager> mScreenManager;
00125 
00126     float mWidthFloat;
00127     float mHeightFloat;
00128     PRInt32 mWidth;
00129     PRInt32 mHeight;
00130 
00131 #if defined(MOZ_ENABLE_GTK2) || defined(MOZ_ENABLE_XLIB)
00132     Drawable mPixmapParentDrawable;
00133 #endif
00134 
00135 #ifdef MOZ_ENABLE_XLIB
00136     XlibRgbHandle *mXlibRgbHandle;
00137 #endif
00138 
00139 };
00140 
00141 #endif /* _NS_CAIRODEVICECONTEXT_H_ */
00142