CCDC Class Reference

#include <ccdc.h>

Inheritance diagram for CCDC:

ListItem CCObject SimpleCCObject CCClientDC CCDummyDC CCPaintDC KernelDC ExportDC PSPrintDC CMXExportDC EPSExportDC FlashExportDC NativeExportDC List of all members.

Public Member Functions

 CCDC (RenderType=RENDERTYPE_NONE)
 Constructor for CCDC. Stores type and zeros rectangle list.
 CCDC (CNativeDC *, RenderType=RENDERTYPE_NONE)
 Constructor for CCDC to base it on an existing CDC. The CDC on which this is based MUST stay in existance while this CCDC is in existence as it 'borrows' the members from the doner CDC.
 ~CCDC ()
 Destructor for CCDC.
CNativeDCGetDC () const
 operator CNativeDC & ()
void SetDC (CNativeDC *dc, BOOL bDeleteDC=TRUE)
RenderType GetRenderType () const
virtual BOOL IsPrinting () const

Static Public Member Functions

static UINT32 GetRectangleList (wxDC *, wxRect **)
 The whole point of CCDCs over normal CDCs is to get additional information. This call allows access to the clipping rectangle list. A zero return is not an error, it just means that the rectangle list is not known.
static RenderType GetType (CNativeDC *, BOOL)
 Get an indication of the type of the render destination.
static BOOL IsPaperWanted (RenderType)
 Used by the document renderer to decide whether paper-like things should be drawn.
static BOOL CleanUpDCs (void)
static CCDCConvertFromNativeDC (CNativeDC *pDC)
 See if a CDC* is really a CCDC* which we can get useful extra information from.

Protected Attributes

RenderType Type
LPRGNDATA lpRgnData
CNativeDCm_pDC
BOOL m_bDeleteDC

Static Protected Attributes

static List s_DCList
 A layer above the MFC CDC class which contains additional information, including a type word (see RenderType) and rectangle list information. Note that is is derived from an MFC class, not CCObject so take care with 'new's and ISRUNTIME checks.

Detailed Description

Definition at line 108 of file ccdc.h.


Constructor & Destructor Documentation

CCDC::CCDC RenderType  rType = RENDERTYPE_NONE  ) 
 

Constructor for CCDC. Stores type and zeros rectangle list.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/93
Parameters:
The type of CCDC that is required. [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: - Scope: Public

See also:
RenderType

Definition at line 163 of file ccdc.cpp.

00164 {
00165     lpRgnData = NULL;
00166     Type = rType;
00167     m_pDC = NULL;
00168     m_bDeleteDC = TRUE;
00169 }

CCDC::CCDC CNativeDC pDC,
RenderType  rType = RENDERTYPE_NONE
 

Constructor for CCDC to base it on an existing CDC. The CDC on which this is based MUST stay in existance while this CCDC is in existence as it 'borrows' the members from the doner CDC.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/93
Parameters:
An exisiting CDC and the type of CCDC that is required. [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: - Scope: Public

Definition at line 188 of file ccdc.cpp.

00189 {
00190     lpRgnData = NULL;
00191     Type = rType;
00192     m_pDC=NULL;
00193     m_bDeleteDC = FALSE;
00194     SetDC(pDC, FALSE); // previously m_pDC = pDC;
00195 }

CCDC::~CCDC  ) 
 

Destructor for CCDC.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None

Errors: - Scope: Public

Definition at line 212 of file ccdc.cpp.

00213 {
00214     SetDC(NULL);
00215     CCFree(lpRgnData);
00216     lpRgnData = NULL;
00217 
00218     // Karim 06/06/2000 - NULLify our handles.
00219 //  m_hDC = NULL;
00220 //  m_hAttribDC = NULL;
00221 }


Member Function Documentation

BOOL CCDC::CleanUpDCs void   )  [static]
 

Definition at line 447 of file ccdc.cpp.

00448 {
00449     // Delete all the entries in the list (the item destructors will delete the DCs)
00450     s_DCList.DeleteAll();
00451 
00452     return(TRUE);
00453 }

CCDC * CCDC::ConvertFromNativeDC CNativeDC pDC  )  [static]
 

See if a CDC* is really a CCDC* which we can get useful extra information from.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/93
Parameters:
Pointer to a CDC. [INPUTS]
None [OUTPUTS]
Returns:
A pointer to a CCDC, or NULL if it cannot be safely cast.

Errors: - Scope: Public

Definition at line 239 of file ccdc.cpp.

00240 {
00241     if (!pDC)
00242         return NULL;
00243 
00244     // Scan the DCList to find the item
00245     CCDC * pItem = (CCDC*)s_DCList.GetHead();
00246     while (pItem)
00247     {
00248         if (pItem->GetDC() == pDC)
00249             return pItem;
00250 
00251         pItem = (CCDC*)s_DCList.GetNext(pItem);
00252     }
00253 
00254     return NULL;
00255 }

CNativeDC* CCDC::GetDC  )  const [inline]
 

Definition at line 124 of file ccdc.h.

00124 { return(m_pDC); }

UINT32 CCDC::GetRectangleList wxDC *  pCDC,
wxRect **  lpRect
[static]
 

The whole point of CCDCs over normal CDCs is to get additional information. This call allows access to the clipping rectangle list. A zero return is not an error, it just means that the rectangle list is not known.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/93
Parameters:
None [INPUTS]
lpRect will point to a rectangle list. XRECT is a 32-bit rectangle, defined [OUTPUTS] in gdimagic.h
Returns:
Number of rectangles in list, or 0 for don't know.

Errors: - Scope: Public

Definition at line 275 of file ccdc.cpp.

00276 {
00277     const CCDC *pCCDC = ConvertFromNativeDC(pCDC);
00278 
00279     if (pCCDC == NULL)
00280         return 0;                                       // if not a CCDC
00281 
00282 #ifndef EXCLUDE_FROM_XARALX
00283     // Multi-region draw hints are only supported on MSW
00284 #if defined( __WXMSW__ )
00285     if (pCCDC->lpRgnData && (pCCDC->lpRgnData->rdh.iType == RDH_RECTANGLES) )
00286     {
00287         *lpRect = (wxRect *)( &pCCDC->lpRgnData->Buffer );  // the address of the rectangle list
00288         return (UINT32)(pCCDC->lpRgnData->rdh.nCount);
00289     }
00290 #endif
00291 #endif
00292     return 0;
00293 }

RenderType CCDC::GetRenderType  )  const [inline]
 

Definition at line 127 of file ccdc.h.

00127 { return Type; }

RenderType CCDC::GetType CNativeDC pDC,
BOOL  bCalculate
[static]
 

Get an indication of the type of the render destination.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/93
Parameters:
Pointer to a wxDC, bCalculate makes it return a valid type for wxDCs by [INPUTS] asking GDI what the pCDC really points to. If bCalculate is FALSE and pCDC cannot be safely cast to a CCDC, returns RENDERTYPE_NONE as we cannot tell.
None [OUTPUTS]
Returns:
The type of the CCDC

Errors: - Scope: Public

See also:
RenderType

Definition at line 313 of file ccdc.cpp.

00314 {
00315     const CCDC *pCCDC = ConvertFromNativeDC( pDC );
00316 
00317     if (pCCDC == NULL)
00318     {
00319         PORTNOTETRACE("other","CCDC::GetType - can't calculate device type yet");
00320 #ifndef EXCLUDE_FROM_XARALX
00321         if (bCalculate)
00322         {
00323             // work out the type from the HDC if he can. We don't use the MFC fn as
00324             // it gets the type from the attrib, not the actual HDC, though this screws
00325             // up with Print Preview
00326             switch ( ::GetDeviceCaps( pDC->m_hDC, TECHNOLOGY ) )
00327             {
00328                 case DT_RASDISPLAY:
00329                     return RENDERTYPE_SCREEN;
00330 
00331                 case DT_PLOTTER:
00332                 case DT_RASPRINTER:
00333                     // Need to detect if this is a PostScript printer - this requires
00334                     // different code on different OSs.
00335                     // (This code taken from MSDN - PSS ID Number: Q124135)
00336                     WORD wEscape;                   
00337 
00338                     if (IsWin32NT() || IsWin32c())
00339                     {
00340                         wEscape = POSTSCRIPT_PASSTHROUGH; // Fails with Win16 driver
00341                         if (pDC->Escape(QUERYESCSUPPORT, sizeof(WORD), (LPCSTR) &wEscape, NULL) > 0)
00342                         {
00343                             // Found a PS printer
00344                             return RENDERTYPE_PRINTER_PS;
00345                         }
00346                     }
00347                     else if (IsWin32s())
00348                     {
00349                         // use printer escape to determine printer type.
00350                         wEscape = GETTECHNOLOGY;
00351                         if (pDC->Escape(QUERYESCSUPPORT, sizeof(WORD), (LPCSTR) &wEscape, NULL) > 0)
00352                         {
00353                             // Supports Escapes - get the technology info.
00354                             char Technology[256];
00355                             pDC->Escape(GETTECHNOLOGY, 0, NULL, 255, Technology);
00356 
00357                             // Does the technology description start with "postscript"?
00358                             if (_tcsncicmp(Technology, "postscript", 10) == 0)
00359                             {
00360                                 // Ok - does it support passthrough?
00361                                 wEscape = PASSTHROUGH;
00362                                 if (pDC->Escape(QUERYESCSUPPORT, sizeof(WORD), 
00363                                                  (LPCSTR) &wEscape, NULL) > 0)
00364                                 {
00365                                     // Found a PS printer
00366                                     return RENDERTYPE_PRINTER_PS;
00367                                 }
00368                             }
00369 
00370                             // GETTECHNOLOGY might not work on some printer drivers, so
00371                             // try another escape - EPSPRINTING - should only work on PS!
00372                             wEscape = EPSPRINTING;
00373                             if (pDC->Escape(QUERYESCSUPPORT, sizeof(WORD), (LPCSTR) &wEscape, NULL) > 0)
00374                             {
00375                                 // Supports EPS printing - must be PostScript.
00376                                 return RENDERTYPE_PRINTER_PS;
00377                             }
00378                         }
00379                     }
00380 
00381                     // If we've got here its a normal (non-PS) printer.
00382                     return RENDERTYPE_PRINTER;
00383 
00384                 case DT_METAFILE:
00385                     return RENDERTYPE_METAFILE16;               // 32-bit metafiles return their
00386                                                                 // context device, which we
00387                                                                 // cannot create anyway as yet
00388             }
00389         }
00390 #endif
00391 
00392         return RENDERTYPE_NONE;
00393     }
00394 
00395     // its an actual CCDC so its type is well-known
00396     return pCCDC->Type;
00397 }

BOOL CCDC::IsPaperWanted RenderType  rType  )  [static]
 

Used by the document renderer to decide whether paper-like things should be drawn.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/93
Parameters:
Type of rendering device [INPUTS]
None [OUTPUTS]
Returns:
TRUE if the device wants paper rendered (pages, backgrounds etc), FALSE if it does not.

Errors: - Scope: Public

Definition at line 416 of file ccdc.cpp.

00417 {
00418     switch (rType)
00419     {
00420         case RENDERTYPE_SCREEN:
00421         case RENDERTYPE_SCREENXOR:
00422             return TRUE;
00423 
00424         case RENDERTYPE_PRINTER:
00425             return FALSE;
00426 
00427         case RENDERTYPE_MONOBITMAP:
00428             return FALSE;
00429         
00430         case RENDERTYPE_HITDETECT:
00431             return FALSE;
00432         
00433         case RENDERTYPE_COLOURBITMAP:
00434             return TRUE;
00435 
00436         case RENDERTYPE_METAFILE16:
00437         case RENDERTYPE_METAFILE32:
00438             return FALSE;
00439 
00440         default:
00441             TRACE( _T("Bad rendertype %d in IsPaperWanted\n"), rType );
00442             return TRUE;
00443     }
00444 }

virtual BOOL CCDC::IsPrinting  )  const [inline, virtual]
 

Definition at line 129 of file ccdc.h.

00129 { return (Type == RENDERTYPE_PRINTER) || (Type == RENDERTYPE_PRINTER_PS); }

CCDC::operator CNativeDC &  )  [inline]
 

Definition at line 125 of file ccdc.h.

00125 { return (*m_pDC); }

void CCDC::SetDC CNativeDC dc,
BOOL  bDeleteDC = TRUE
 

Definition at line 456 of file ccdc.cpp.

00457 {
00458     if (m_pDC == dc)
00459         return;
00460 
00461     if (m_pDC)
00462     {
00463         if (m_bDeleteDC)
00464             delete (m_pDC);
00465         // take us off the list
00466         s_DCList.RemoveItem(this);
00467     }
00468     m_pDC = dc;
00469     if (m_pDC)
00470     {
00471         m_bDeleteDC = bDeleteDC;
00472         // put us on the list
00473         s_DCList.AddTail(this);
00474     }
00475 }


Member Data Documentation

LPRGNDATA CCDC::lpRgnData [protected]
 

Definition at line 119 of file ccdc.h.

BOOL CCDC::m_bDeleteDC [protected]
 

Definition at line 121 of file ccdc.h.

CNativeDC* CCDC::m_pDC [protected]
 

Definition at line 120 of file ccdc.h.

List CCDC::s_DCList [static, protected]
 

A layer above the MFC CDC class which contains additional information, including a type word (see RenderType) and rectangle list information. Note that is is derived from an MFC class, not CCObject so take care with 'new's and ISRUNTIME checks.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/11/93
See also:
CDC;CCPaintDC

Definition at line 140 of file ccdc.h.

RenderType CCDC::Type [protected]
 

Definition at line 118 of file ccdc.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:04 2007 for Camelot by  doxygen 1.4.4