Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes

GR_Win32Graphics Class Reference

#include <gr_Win32Graphics.h>

Inheritance diagram for GR_Win32Graphics:
GR_Graphics GR_Win32PrintPreviewGraphics GR_Win32USPGraphics

List of all members.


struct  _HDCSwitchRecord
struct  CACHE_PEN

Public Member Functions

virtual ~GR_Win32Graphics ()
virtual UT_uint32 getClassId ()
virtual GR_Capability getCapability ()
virtual void drawGlyph (UT_uint32 glyph_idx, UT_sint32 xoff, UT_sint32 yoff)
virtual void drawChar (UT_UCSChar Char, UT_sint32 xoff, UT_sint32 yoff)
virtual void drawChars (const UT_UCSChar *pChars, int iCharOffset, int iLength, UT_sint32 xoff, UT_sint32 yoff, int *pCharWidth)
virtual void setFont (const GR_Font *pFont)
virtual void clearFont (void)
virtual UT_uint32 getFontHeight ()
virtual UT_sint32 measureUnRemappedChar (const UT_UCSChar c, UT_uint32 *height=0)
virtual void setColor (const UT_RGBColor &clr)
virtual void getColor (UT_RGBColor &clr)
virtual GR_FontgetGUIFont ()
virtual UT_uint32 getFontAscent ()
virtual UT_uint32 getFontDescent ()
virtual void getCoverage (UT_NumberVector &coverage)
virtual void drawLine (UT_sint32, UT_sint32, UT_sint32, UT_sint32)
virtual void xorLine (UT_sint32, UT_sint32, UT_sint32, UT_sint32)
virtual void setLineWidth (UT_sint32)
virtual void setLineProperties (double inWidthPixels, JoinStyle inJoinStyle=JOIN_MITER, CapStyle inCapStyle=CAP_BUTT, LineStyle inLineStyle=LINE_SOLID)
virtual void polyLine (UT_Point *pts, UT_uint32 nPoints)
virtual void fillRect (const UT_RGBColor &c, UT_sint32 x, UT_sint32 y, UT_sint32 w, UT_sint32 h)
virtual void invertRect (const UT_Rect *pRect)
virtual void setClipRect (const UT_Rect *pRect)
virtual void scroll (UT_sint32 dx, UT_sint32 dy)
 The View calls this when it receives a SetX/YScrollOffset call.
virtual void scroll (UT_sint32 x_dest, UT_sint32 y_dest, UT_sint32 x_src, UT_sint32 y_src, UT_sint32 width, UT_sint32 height)
virtual void clearArea (UT_sint32, UT_sint32, UT_sint32, UT_sint32)
virtual void drawImage (GR_Image *pImg, UT_sint32 xDest, UT_sint32 yDest)
virtual GR_ImagecreateNewImage (const char *pszName, const UT_ByteBuf *pBB, const std::string &mimetype, UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight, GR_Image::GRType iType=GR_Image::GRT_Raster)
virtual bool queryProperties (GR_Graphics::Properties gp) const
virtual bool startPrint (void)
virtual bool startPage (const char *szPageLabel, UT_uint32 pageNumber, bool bPortrait, UT_uint32 iWidth, UT_uint32 iHeight)
virtual bool endPrint (void)
virtual HWND getHwnd (void) const
virtual void setColorSpace (GR_Graphics::ColorSpace c)
virtual GR_Graphics::ColorSpace getColorSpace (void) const
virtual void setCursor (GR_Graphics::Cursor c)
virtual GR_Graphics::Cursor getCursor (void) const
virtual void handleSetCursorMessage (void)
virtual void setColor3D (GR_Color3D c)
void init3dColors (void)
virtual void fillRect (GR_Color3D c, UT_sint32 x, UT_sint32 y, UT_sint32 w, UT_sint32 h)
virtual void fillRect (GR_Color3D c, UT_Rect &r)
virtual void polygon (UT_RGBColor &c, UT_Point *pts, UT_uint32 nPoints)
virtual UT_uint32 getFontAscent (const GR_Font *)
virtual UT_uint32 getFontDescent (const GR_Font *)
virtual UT_uint32 getFontHeight (const GR_Font *)
virtual GR_ImagegenImageFromRectangle (const UT_Rect &r)
virtual void saveRectangle (UT_Rect &r, UT_uint32 iIndx)
virtual void restoreRectangle (UT_uint32 iIndx)
virtual void flush (void)
void setBrush (HBRUSH hBrush)
virtual void setPrintDC (HDC dc)
HDC getPrintDC () const
HDC getPrimaryDC () const
void setPrintDCFontAllocNo (UT_uint32 i)
void setDCFontAllocNo (UT_uint32 i)
double getXYRatio () const
double getXYRatioPrint () const

Static Public Member Functions

static UT_uint32 s_getClassId ()
static const char * graphicsDescriptor ()
static GR_GraphicsgraphicsAllocator (GR_AllocInfo &)
static GR_GraphicsgetPrinterGraphics (const wchar_t *pPrinterName, const wchar_t *pDocName)
static bool fixDevMode (HGLOBAL hModDev)
static DOCINFOW * getDocInfo ()
static HDC createbestmetafilehdc ()

Protected Member Functions

 GR_Win32Graphics (HDC, HWND)
 GR_Win32Graphics (HDC, const DOCINFOW *, HGLOBAL hDevMode=NULL)
virtual GR_Font_findFont (const char *pszFontFamily, const char *pszFontStyle, const char *pszFontVariant, const char *pszFontWeight, const char *pszFontStretch, const char *pszFontSize, const char *pszLang)
virtual UT_uint32 getDeviceResolution (void) const
void _setColor (DWORD clrRef)
void _DeviceContext_MeasureBitBltCopySpeed (HDC source, HDC dest, int width, int height)
void getWidthAndHeightFromHWND (HWND h, int &width, int &height)
void _DeviceContext_SwitchToBuffer ()
void _DeviceContext_SwitchToScreen ()
void _DeviceContext_DrawBufferToScreen ()
void _DeviceContext_SuspendDrawing ()
void _DeviceContext_ResumeDrawing ()
void _DoubleBuffering_SetUpDummyBuffer ()
void _DoubleBuffering_ReleaseDummyBuffer ()
HDC _DoubleBuffering_CreateBuffer (HDC, int, int)
void _DoubleBuffering_ReleaseBuffer (HDC)
void _DeviceContext_RestorePrevHDCFromStack ()

Protected Attributes

HDC m_bufferHdc
HDC m_dummyHdc
UT_Stack _HDCSwitchStack
UT_uint32 m_iDCFontAllocNo
UT_uint32 m_iPrintDCFontAllocNo
HDC m_hdc
HDC m_printHDC
HWND m_hwnd
const DOCINFOW * m_pDocInfo
bool m_bPrint
bool m_bStartPrint
bool m_bStartPage
UT_sint32 m_iLineWidth
JoinStyle m_eJoinStyle
CapStyle m_eCapStyle
LineStyle m_eLineStyle
GR_Graphics::ColorSpace m_cs
GR_Graphics::Cursor m_cursor
DWORD m_clrCurrent
int m_nPrintLogPixelsY
double m_fXYRatio
double m_fXYRatioPrint

Static Protected Attributes

static HDC m_defPrintHDC = NULL
static UT_uint32 s_iInstanceCount = 0

Private Member Functions

virtual GR_Win32Font_newFont (LOGFONTW &lf, double fPointSize, HDC hdc, HDC printDC)
void _constructorCommonCode (HDC)
UT_uint16_remapGlyphs (const UT_UCSChar *pChars, int iCharOffset, int &iLength)
virtual bool _setTransform (const GR_Transform &tr)

Private Attributes

DWORD m_clrXorPen
HPEN m_hXorPen
UT_uint32 m_remapBufferSize
UT_RGBColor m_curColor
UT_Vector m_vSaveRect
UT_Vector m_vSaveRectBuf
HBRUSH m_hClearBrush
int m_nLogPixelsY
HGLOBAL m_hDevMode
int m_nArPenPos
bool m_bIsPreview

Constructor & Destructor Documentation

GR_Win32Graphics::GR_Win32Graphics ( HDC  hdc,
HWND  hwnd 
) [protected]
GR_Win32Graphics::GR_Win32Graphics ( HDC  hdc,
const DOCINFOW *  pDocInfo,
) [protected]

Member Function Documentation

void GR_Win32Graphics::_DeviceContext_DrawBufferToScreen (  )  [protected]
void GR_Win32Graphics::_DeviceContext_MeasureBitBltCopySpeed ( HDC  source,
HDC  dest,
int  width,
int  height 
) [protected]

References UT_DEBUGMSG.

void GR_Win32Graphics::_DeviceContext_RestorePrevHDCFromStack (  )  [protected]
void GR_Win32Graphics::_DeviceContext_ResumeDrawing (  )  [protected, virtual]

Reimplemented from GR_Graphics.

References _DeviceContext_RestorePrevHDCFromStack().

void GR_Win32Graphics::_DeviceContext_SuspendDrawing (  )  [protected, virtual]

Reimplemented from GR_Graphics.

References _HDCSwitchStack, m_dummyHdc, m_hdc, and UT_Stack::push().

void GR_Win32Graphics::_DeviceContext_SwitchToBuffer (  )  [protected, virtual]
void GR_Win32Graphics::_DeviceContext_SwitchToScreen (  )  [protected, virtual]
HDC GR_Win32Graphics::_DoubleBuffering_CreateBuffer ( HDC  compatibleWith,
int  width,
int  height 
) [protected]
void GR_Win32Graphics::_DoubleBuffering_ReleaseBuffer ( HDC  hdc  )  [protected]
void GR_Win32Graphics::_DoubleBuffering_ReleaseDummyBuffer (  )  [protected]
void GR_Win32Graphics::_DoubleBuffering_SetUpDummyBuffer (  )  [protected]
GR_Font * GR_Win32Graphics::_findFont ( const char *  pszFontFamily,
const char *  pszFontStyle,
const char *  pszFontVariant,
const char *  pszFontWeight,
const char *  pszFontStretch,
const char *  pszFontSize,
const char *  pszLang 
) [protected, virtual]
GR_Win32Font * GR_Win32Graphics::_newFont ( LOGFONTW &  lf,
double  fPointSize,
HDC  hdc,
HDC  printDC 
) [private, virtual]

Reimplemented in GR_Win32USPGraphics.

References GR_Win32Font::newFont().

Referenced by getGUIFont().

UT_uint16 * GR_Win32Graphics::_remapGlyphs ( const UT_UCSChar pChars,
int  iCharOffset,
int &  iLength 
) [private]
void GR_Win32Graphics::_setColor ( DWORD  clrRef  )  [protected]

References m_clrCurrent, and m_hdc.

Referenced by setColor(), and setColor3D().

bool GR_Win32Graphics::_setTransform ( const GR_Transform tr  )  [private, virtual]
void GR_Win32Graphics::clearArea ( UT_sint32  x,
UT_sint32  y,
UT_sint32  width,
UT_sint32  height 
) [virtual]
virtual void GR_Win32Graphics::clearFont ( void   )  [inline, virtual]
BITMAPINFO * GR_Win32Graphics::ConvertDDBToDIB ( HBITMAP  bitmap,
DWORD  dwCompression 
) [protected]

References BOOL(), and m_hdc.

Referenced by genImageFromRectangle().

HDC GR_Win32Graphics::createbestmetafilehdc (  )  [static]
GR_Image * GR_Win32Graphics::createNewImage ( const char *  pszName,
const UT_ByteBuf pBB,
const std::string &  mimetype,
UT_sint32  iDisplayWidth,
UT_sint32  iDisplayHeight,
GR_Image::GRType  iType = GR_Image::GRT_Raster 
) [virtual]
void GR_Win32Graphics::drawGlyph ( UT_uint32  glyph_idx,
UT_sint32  xoff,
UT_sint32  yoff 
) [virtual]

Implements GR_Graphics.

Reimplemented in GR_Win32PrintPreviewGraphics.


bool GR_Win32Graphics::endPrint ( void   )  [virtual]

Implements GR_Graphics.

Reimplemented in GR_Win32PrintPreviewGraphics.

References m_bIsPreview, m_bStartPage, and m_hdc.

void GR_Win32Graphics::fillRect ( GR_Color3D  c,
UT_sint32  x,
UT_sint32  y,
UT_sint32  w,
UT_sint32  h 
) [virtual]
void GR_Win32Graphics::fillRect ( GR_Color3D  c,
UT_Rect r 
) [virtual]
void GR_Win32Graphics::fillRect ( const UT_RGBColor c,
UT_sint32  x,
UT_sint32  y,
UT_sint32  w,
UT_sint32  h 
) [virtual]
bool GR_Win32Graphics::fixDevMode ( HGLOBAL  hDevMode  )  [static]

This function absolutely must be called anytime the DEVMODE structure is modified in any way; it also must be called on the DEVMODE handle returned by PringDlg. Those who will modify DEVMODE structure and not call this function on it will be shot, without exception.

The issue with the DEVMODE structure is this: it consists of two parts, a public part declared by the win32 headers, and a private part, the size and contents of which depend on the printer. Before a printer can be passed the DEVMODE structure, two things have to be satisfied:

1. The memory allocated for the structure has to be large enough to hold both the public and private parts of the structure; we obtain the handle from the PrintDlg, and it _should_ allocate the necessary size correctly. In any case, we cannot meddle with the size, since reallocating means loosing the private part.

2. The settings represented by the public part have to be transferred into the private part; this is achieved by calling the DocumentProperties() function on the structure. So any time we modify the contents of DEVMODE in any way we have to call DocumentProperties() before we can pass the pointer / handle to any other function. In addition, I have a strong suspicion that the PrintDlg function only sets the public section, but does not call DocumentProperties(), so we have to do that ourselves once we get the handle back.

References UT_String::c_str(), LOG_WIN32_EXCPT, UT_ASSERT_HARMLESS, UT_return_val_if_fail, UT_SHOULD_NOT_HAPPEN, and UT_String_sprintf().

Referenced by XAP_Win32Dialog_Print::_extractResults(), and startPage().

void GR_Win32Graphics::flush ( void   )  [virtual]

Reimplemented from GR_Graphics.

Reimplemented in GR_Win32PrintPreviewGraphics.

GR_Image * GR_Win32Graphics::genImageFromRectangle ( const UT_Rect r  )  [virtual]
virtual GR_Capability GR_Win32Graphics::getCapability (  )  [inline, virtual]

Reimplemented from GR_Graphics.

Reimplemented in GR_Win32USPGraphics, and GR_Win32PrintPreviewGraphics.

virtual UT_uint32 GR_Win32Graphics::getClassId (  )  [inline, virtual]

Implements GR_Graphics.

Reimplemented in GR_Win32USPGraphics, and GR_Win32PrintPreviewGraphics.

void GR_Win32Graphics::getColor ( UT_RGBColor clr  )  [virtual]

Implements GR_Graphics.

Reimplemented in GR_Win32PrintPreviewGraphics.

References m_curColor.

GR_Graphics::ColorSpace GR_Win32Graphics::getColorSpace ( void   )  const [virtual]

Implements GR_Graphics.

References m_cs.

void GR_Win32Graphics::getCoverage ( UT_NumberVector coverage  )  [virtual]
GR_Graphics::Cursor GR_Win32Graphics::getCursor ( void   )  const [virtual]

Implements GR_Graphics.

References m_cursor.

UT_uint32 GR_Win32Graphics::getDeviceResolution ( void   )  const [protected, virtual]
DOCINFOW * GR_Win32Graphics::getDocInfo (  )  [static]

References UT_calloc().

Referenced by GR_Graphics::newNullGraphics().

UT_uint32 GR_Win32Graphics::getFontAscent (  )  [virtual]
UT_uint32 GR_Win32Graphics::getFontAscent ( const GR_Font fnt  )  [virtual]

Implements GR_Graphics.

References getFontAscent(), m_pFont, and setFont().

UT_uint32 GR_Win32Graphics::getFontDescent (  )  [virtual]
UT_uint32 GR_Win32Graphics::getFontDescent ( const GR_Font fnt  )  [virtual]

Implements GR_Graphics.

References getFontDescent(), m_pFont, and setFont().

UT_uint32 GR_Win32Graphics::getFontHeight (  )  [virtual]
UT_uint32 GR_Win32Graphics::getFontHeight ( const GR_Font fnt  )  [virtual]

Implements GR_Graphics.

References getFontHeight(), m_pFont, and setFont().

GR_Font * GR_Win32Graphics::getGUIFont ( void   )  [virtual]
HWND GR_Win32Graphics::getHwnd ( void   )  const [virtual]

References m_hwnd.

GR_Graphics * GR_Win32Graphics::getPrinterGraphics ( const wchar_t *  pPrinterName,
const wchar_t *  pDocName 
) [static]
void GR_Win32Graphics::getWidthAndHeightFromHWND ( HWND  h,
int &  width,
int &  height 
) [protected]
double GR_Win32Graphics::getXYRatio (  )  const [inline]
double GR_Win32Graphics::getXYRatioPrint (  )  const [inline]
GR_Graphics * GR_Win32Graphics::graphicsAllocator ( GR_AllocInfo info  )  [static]
static const char* GR_Win32Graphics::graphicsDescriptor (  )  [inline, static]
void GR_Win32Graphics::invertRect ( const UT_Rect pRect  )  [virtual]
void GR_Win32Graphics::polygon ( UT_RGBColor c,
UT_Point pts,
UT_uint32  nPoints 
) [virtual]
void GR_Win32Graphics::polyLine ( UT_Point pts,
UT_uint32  nPoints 
) [virtual]
bool GR_Win32Graphics::queryProperties ( GR_Graphics::Properties  gp  )  const [virtual]
static UT_uint32 GR_Win32Graphics::s_getClassId (  )  [inline, static]
void GR_Win32Graphics::scroll ( UT_sint32  x_dest,
UT_sint32  y_dest,
UT_sint32  x_src,
UT_sint32  y_src,
UT_sint32  width,
UT_sint32  height 
) [virtual]

Implements GR_Graphics.

References m_fXYRatio, m_hwnd, and GR_Graphics::tdu().

void GR_Win32Graphics::scroll ( UT_sint32  dx,
UT_sint32  dy 
) [virtual]

The View calls this when it receives a SetX/YScrollOffset call.

Move the contents of the window appropriately. View will draw after you exit from this call. View will only draw into the "exposed" area.

dx & dy are the change in x/y from the current scrolled position negative values indcate left/up movement, positive right/down movement

Implements GR_Graphics.

References GR_Graphics::getPrevXOffset(), GR_Graphics::getPrevYOffset(), m_fXYRatio, m_hwnd, GR_Graphics::setPrevXOffset(), GR_Graphics::setPrevYOffset(), and GR_Graphics::tdu().

void GR_Win32Graphics::setBrush ( HBRUSH  hBrush  )  [inline]

Referenced by _constructorCommonCode().

void GR_Win32Graphics::setClipRect ( const UT_Rect pRect  )  [virtual]
void GR_Win32Graphics::setColor ( const UT_RGBColor clr  )  [virtual]
void GR_Win32Graphics::setColor3D ( GR_Color3D  c  )  [virtual]
void GR_Win32Graphics::setColorSpace ( GR_Graphics::ColorSpace  c  )  [virtual]

Implements GR_Graphics.


void GR_Win32Graphics::setCursor ( GR_Graphics::Cursor  c  )  [virtual]

Implements GR_Graphics.

References m_cursor.

Referenced by _constructorCommonCode().

void GR_Win32Graphics::setDCFontAllocNo ( UT_uint32  i  )  [inline]

Referenced by GR_Win32Font::glyphBox().

void GR_Win32Graphics::setLineProperties ( double  inWidthPixels,
JoinStyle  inJoinStyle = JOIN_MITER,
CapStyle  inCapStyle = CAP_BUTT,
LineStyle  inLineStyle = LINE_SOLID 
) [virtual]
void GR_Win32Graphics::setLineWidth ( UT_sint32  iLineWidth  )  [virtual]

Implements GR_Graphics.

Reimplemented in GR_Win32PrintPreviewGraphics.

References m_iLineWidth.

void GR_Win32Graphics::setPrintDC ( HDC  dc  )  [virtual]

Reimplemented in GR_Win32USPGraphics.

References m_bPrint, and m_printHDC.

Referenced by XAP_Win32Dialog_Print::runModal().

void GR_Win32Graphics::setPrintDCFontAllocNo ( UT_uint32  i  )  [inline]

Referenced by GR_Win32Font::glyphBox().

bool GR_Win32Graphics::startPage ( const char *  szPageLabel,
UT_uint32  pageNumber,
bool  bPortrait,
UT_uint32  iWidth,
UT_uint32  iHeight 
) [virtual]
bool GR_Win32Graphics::startPrint ( void   )  [virtual]
void GR_Win32Graphics::xorLine ( UT_sint32  x1,
UT_sint32  y1,
UT_sint32  x2,
UT_sint32  y2 
) [virtual]

Member Data Documentation

DWORD GR_Win32Graphics::m_3dColors[COUNT_3D_COLORS] [protected]

Referenced by fillRect(), init3dColors(), and setColor3D().

Referenced by clearArea().

const DOCINFOW* GR_Win32Graphics::m_pDocInfo [protected]

Referenced by GR_Win32Graphics(), and startPrint().

Reimplemented from GR_Graphics.

Reimplemented in GR_Win32USPGraphics.

Referenced by GR_Win32Graphics(), and ~GR_Win32Graphics().

The documentation for this class was generated from the following files: