gecko-dev/gfx/src/nsIDeviceContext.h

157 lines
5.3 KiB
C
Raw Normal View History

1998-04-13 20:24:54 +00:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIDeviceContext_h___
#define nsIDeviceContext_h___
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsRect.h"
#include "nsIWidget.h"
1998-04-13 20:24:54 +00:00
class nsIRenderingContext;
1998-04-13 20:24:54 +00:00
class nsIView;
class nsIFontCache;
class nsIFontMetrics;
class nsIWidget;
struct nsFont;
//a cross platform way of specifying a navite device context
typedef void * nsNativeDeviceContext;
1998-04-13 20:24:54 +00:00
#define NS_IDEVICE_CONTEXT_IID \
{ 0x5931c580, 0xb917, 0x11d1, \
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
1998-08-19 00:37:05 +00:00
//a cross platform way of specifying a native palette handle
typedef void * nsPalette;
//structure used to return information about a device's palette capabilities
struct nsPaletteInfo {
PRPackedBool isPaletteDevice;
PRUint8 sizePalette; // number of entries in the palette
PRUint8 numReserved; // number of reserved palette entries
nsPalette palette; // native palette handle
};
1998-07-26 04:28:48 +00:00
/**
* Constants identifying pre-defined icons.
* @see #LoadIcon()
*/
#define NS_ICON_LOADING_IMAGE 0
#define NS_ICON_BROKEN_IMAGE 1
#define NS_NUMBER_OF_ICONS 2
1998-07-26 04:28:48 +00:00
// XXX This is gross, but don't include libimg.h, because it includes ni_pixmap.h
// which includes xp_core.h which includes windows.h
struct _NI_ColorSpace;
typedef _NI_ColorSpace NI_ColorSpace;
typedef NI_ColorSpace IL_ColorSpace;
1998-04-13 20:24:54 +00:00
class nsIDeviceContext : public nsISupports
{
public:
NS_IMETHOD Init(nsNativeWidget aWidget) = 0;
1998-04-13 20:24:54 +00:00
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) = 0;
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow) = 0;
1998-04-13 20:24:54 +00:00
//these are queries to figure out how large an output unit
//(i.e. pixel) is in terms of twips (1/20 of a point)
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const = 0;
NS_IMETHOD GetTwipsToDevUnits(float &aTwipsToDevUnits) const = 0;
1998-04-13 20:24:54 +00:00
//these are set by the object that created this
//device context to define what the scale is
//between the units used by the app and the
//device units
virtual void SetAppUnitsToDevUnits(float aAppUnits) = 0;
virtual void SetDevUnitsToAppUnits(float aDevUnits) = 0;
//these are used to query the scale values defined
//by the above Set*() methods
virtual float GetAppUnitsToDevUnits() const = 0;
virtual float GetDevUnitsToAppUnits() const = 0;
NS_IMETHOD GetScrollBarWidth(float &aWidth) const = 0;
NS_IMETHOD GetScrollBarHeight(float &aHeight) const = 0;
1998-04-13 20:24:54 +00:00
//be sure to Relase() after you are done with the Get()
virtual nsIFontCache * GetFontCache() = 0;
virtual void FlushFontCache() = 0;
// Get the font metrics for a given font.
virtual nsIFontMetrics* GetMetricsFor(const nsFont& aFont) = 0;
//get and set the document zoom value used for display-time
//scaling. default is 1.0 (no zoom)
virtual void SetZoom(float aZoom) = 0;
virtual float GetZoom() const = 0;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext) = 0;
//functions for handling gamma correction of output device
virtual float GetGamma(void) = 0;
virtual void SetGamma(float aGamma) = 0;
//XXX the return from this really needs to be ref counted somehow. MMP
virtual PRUint8 * GetGammaTable(void) = 0;
virtual nsNativeWidget GetNativeWidget(void) = 0;
1998-07-26 04:28:48 +00:00
//load the specified icon. this is a blocking call that does not return
//until the icon is loaded.
//release the image when you're done
NS_IMETHOD LoadIconImage(PRInt32 aId, nsIImage*& aImage) = 0;
1998-08-01 21:37:40 +00:00
/**
* Check to see if a particular named font exists.
* @param aFontName character string of font face name
* @return NS_OK if font is available, else font is unavailable
*/
NS_IMETHOD CheckFontExistence(const nsString& aFaceName) = 0;
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName) = 0;
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
PRBool& aAliased) = 0;
1998-08-05 15:26:15 +00:00
/**
* Return the bit depth of the device.
*/
NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
/**
* Return the image lib color space that's appropriate for this rendering
* context.
*
* You must call IL_ReleaseColorSpace() when you're done using the color space.
*/
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace) = 0;
1998-08-19 00:37:05 +00:00
/**
* Returns information about the device's palette capabilities.
*/
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&) = 0;
1998-04-13 20:24:54 +00:00
};
#endif /* nsIDeviceContext_h___ */