GRenderClick Class Reference

Special version of a GRenderRegion that renders into a mono bitmap. It is used for hit-detection only. It can also be asked if it is 'blank'. More...

#include <grndclik.h>

Inheritance diagram for GRenderClick:

GRenderDIB GRenderRegion RenderRegion ListItem CCObject SimpleCCObject GRenderClickColour GRenderClickColourNoPaper List of all members.

Public Member Functions

 GRenderClick (DocRect ClipRegion, Matrix ConvertMatrix, FIXED16 ViewScale, UINT32 Depth, double dpi)
 Constructor. Most important job is to set the VeryMono flag. Do not call directly, use OSRenderBitmap::Create INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.
 ~GRenderClick ()
 Destructor. Simple cleanup, which involves deleting the RenderDC.
virtual void DebugMe (INT32 Stretch)
 Dupms the current bitmap onto the current view window, so we can see what is going on. Do not call directly, use OSRenderBitmap::DebugMe.
virtual BOOL ImmediateRender ()
 Used to Draw something immediately.
virtual BOOL SetFirstBand ()
 Sets up for banded rendering. This class does not do banded rendering as yet. This just sets things up to indicate that everything will be done in one band.
virtual BOOL GetNextBand ()
 Since this class does not do banded rendering, there are never any more bands.

Protected Member Functions

LPBITMAPINFO GetLPBits (INT32 Width, INT32 Height, INT32 Depth, LPBYTE *)
 Allocates a bitmap from the CCMalloc heap.
void FreeLPBits (LPBITMAPINFO, LPBYTE)
 Frees the memory allocated in GetLPBits.
virtual BitmapContents GetContents (BOOL)
 To investigate whether anything has been rendered into a bitmap-based render region. Don't call directly, use OSRenderBitmap::GetContents.
BOOL DisplayBits (LPBITMAPINFO lpDisplayBitmapInfo=NULL, LPBYTE lpDisplayBits=NULL)
 Supposed to dump bitmap on screen, but that makes no sense for this bitmap so it just does nothing and always returns TRUE.
virtual void SetClean (BOOL bResetChangedBounds, BOOL FillWhite)
 Clears out the RR, both logically and (optionally) physically).
BOOL AttachDevice (View *, wxDC *, Spread *SpreadToAttach=NULL, bool fOwned=false)
 Most work done in base class, except for the creation of a CCDC member.
BOOL StartRender ()
 Most work done in base class, except for the calculation of the address & mask of the centre pixel.

Protected Attributes

LPBYTE pMiddle
BYTE MiddleMask
BOOL ClearOnStart

Friends

class OSRenderBitmap

Detailed Description

Special version of a GRenderRegion that renders into a mono bitmap. It is used for hit-detection only. It can also be asked if it is 'blank'.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94

Definition at line 118 of file grndclik.h.


Constructor & Destructor Documentation

GRenderClick::GRenderClick DocRect  ClipRegion,
Matrix  ConvertMatrix,
FIXED16  ViewScale,
UINT32  Depth,
double  dpi
 

Constructor. Most important job is to set the VeryMono flag. Do not call directly, use OSRenderBitmap::Create INT32 dpi changed to double dpi (12/12/95) to improve the range of values allowed at the < 1000dpi settings that we will be using.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94
Parameters:
A clip region, conversion matrix, scale and bitmap depth. [INPUTS]
None [OUTPUTS]
Returns:
None

Definition at line 131 of file grndclik.cpp.

00132     : GRenderDIB(ClipRegion, ConvertMatrix, ViewScale, Depth, dpi)
00133 {
00134     pMiddle = NULL;                             // just in case used before set up
00135     RenderFlags.VeryMono = TRUE;                // simple black&white rendering
00136     ClearOnStart = FALSE;
00137 }

GRenderClick::~GRenderClick  ) 
 

Destructor. Simple cleanup, which involves deleting the RenderDC.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94

Definition at line 204 of file grndclik.cpp.

00205 {
00206     // Free up the bitmap here, as the call to FreeLPBits in the
00207     // GRenderDIB will not call the correct version (the virtual-ness will be
00208     // broken as it is called from a destructor
00209     if (pBitmapInfo!=NULL)
00210     {
00211 //      FreeLPBits( lpBitmapInfo, lpBits );
00212         FreeOffscreenState();
00213         pBitmapInfo = NULL;
00214         pBits = NULL;
00215     }
00216 }


Member Function Documentation

BOOL GRenderClick::AttachDevice View pView,
wxDC *  DCToAttach,
Spread SpreadToAttach = NULL,
bool  fOwned = false
[protected, virtual]
 

Most work done in base class, except for the creation of a CCDC member.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94
Parameters:
pView is used for debug purposes only. DCToAttach is used as a [INPUTS] reference when making the bitmap.
Returns:
FALSE if failed (no mem for bitmap or CCDC), TRUE if OK

Reimplemented from GRenderRegion.

Reimplemented in GRenderClickColour, and GRenderClickColourNoPaper.

Definition at line 619 of file grndclik.cpp.

00620 {
00621 
00622     // call base class first
00623     if (!GRenderDIB::AttachDevice(pView, DCToAttach, SpreadToAttach, fOwned))
00624         return FALSE;
00625             
00626     // now replace the usual RenderDC with our new one. This makes the type of the CCDC
00627     // correct, so Quality rendering works correctly, for example.
00628 /*
00629     TRY
00630     {
00631         // IMPORTANT: we 'borrow' the HDC from DCToAttach. We must take care when
00632         // deleting this not to delete the HDCs (see the constructor).
00633         RenderDC = new CCDC( DCToAttach, RENDERTYPE_MONOBITMAP );
00634     }
00635     CATCH (CMemoryException, e)
00636     {
00637         // Ooer - not enough memory
00638         TRACEALL( _T("No memory for CCDC in GRenderClick::AttachDevice") );
00639         return FALSE;
00640     }
00641     END_CATCH
00642 */
00643     RenderDC = new wxBufferedDC() ;
00644     m_fOwned = true;
00645 
00646     return TRUE;
00647 }

void GRenderClick::DebugMe INT32  Stretch  )  [virtual]
 

Dupms the current bitmap onto the current view window, so we can see what is going on. Do not call directly, use OSRenderBitmap::DebugMe.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Parameters:
How much you want the image stretched by [INPUTS]
See also:
OSRenderBitmap::DebugMe

Reimplemented in GRenderClickColour.

Definition at line 525 of file grndclik.cpp.

00526 {
00527 #if defined(_DEBUG) && 0        // GAT
00528     DWORD *rgb = (DWORD*)lpBitmapInfo->bmiColors;
00529 
00530     rgb[0] = RGB(0,0,0);
00531     rgb[1] = RGB(255,255,255);
00532 
00533     const INT32 w = WRect.width;
00534     const INT32 h = WRect.height;
00535 
00536     ::StretchDIBits( RenderDC->m_hDC, 0,0, w*Stretch, h*Stretch,
00537                         0,0,w,h,
00538                         lpBits, lpBitmapInfo,
00539                         DIB_RGB_COLORS,
00540                         SRCCOPY
00541                     );
00542 #endif
00543 }

BOOL GRenderClick::DisplayBits LPBITMAPINFO  lpDisplayBitmapInfo = NULL,
LPBYTE  lpDisplayBits = NULL
[protected, virtual]
 

Supposed to dump bitmap on screen, but that makes no sense for this bitmap so it just does nothing and always returns TRUE.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/94
Returns:
TRUE always (cannot fail).

Reimplemented from GRenderDIB.

Definition at line 599 of file grndclik.cpp.

00600 {
00601     return TRUE;
00602 }

void GRenderClick::FreeLPBits LPBITMAPINFO  lpBMI,
LPBYTE  lpB
[protected, virtual]
 

Frees the memory allocated in GetLPBits.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/5/95

Reimplemented from GRenderDIB.

Definition at line 906 of file grndclik.cpp.

00907 {
00908     // Free up the memory. Not from Limited Heap
00909     FreeDIB(lpBMI, lpB, NULL, FALSE);
00910 }

BitmapContents GRenderClick::GetContents BOOL  JustMiddle  )  [protected, virtual]
 

To investigate whether anything has been rendered into a bitmap-based render region. Don't call directly, use OSRenderBitmap::GetContents.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94
Parameters:
If justmiddle is TRUE, only checks on the centre pixel will be done (which [INPUTS] is faster).
None [OUTPUTS]
Returns:
BITMAPCONTENTS_CENTRE if centre pixel is set, _ANY if any pixel is set, _NONE if none and _ERROR if failed for some reason.
See also:
OSRenderBitmap::GetContents

Reimplemented in GRenderClickColour.

Definition at line 335 of file grndclik.cpp.

00336 {
00337     RECT UsedRect;
00338 
00339     if (
00340         HaveRenderedSomething &&
00341         (GetDrawContext()->GetChangedBBox( &UsedRect ))
00342        )
00343     {
00344         if (
00345             (UsedRect.right > UsedRect.left) ||
00346             (UsedRect.top < UsedRect.bottom)
00347            )
00348         {
00349             // something has been drawn - is it the middle?
00350             if ( (*pMiddle & MiddleMask) == 0)
00351                 return BITMAPCONTENTS_CENTRE;
00352 
00353             // if only interested in centre pixel then we're out of here
00354             if (JustMiddle)
00355                 return BITMAPCONTENTS_NONE;
00356 
00357             // not in the middle - if any byte is not 0xFF then something must have been
00358             // rendered
00359             LPDWORD Search = (LPDWORD)pBits;
00360             size_t Count = pBitmapInfo->bmiHeader.biSizeImage >> 2;
00361             while (Count--)
00362             {
00363                 if (*Search != 0xFFFFFFFF)
00364                     return BITMAPCONTENTS_ANY;
00365                 Search++;
00366             }
00367             // else nothing rendered
00368         }
00369     }
00370 
00371     return BITMAPCONTENTS_NONE;
00372 }

LPBITMAPINFO GRenderClick::GetLPBits INT32  Width,
INT32  Height,
INT32  Depth,
LPBYTE lplpBits
[protected, virtual]
 

Allocates a bitmap from the CCMalloc heap.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/5/95
Parameters:
Width,Height - the width and height of the required bitmap [INPUTS] Depth - the bpp of the bitmap
Returns:
Pointer to a bitmap header block

Reimplemented from GRenderDIB.

Definition at line 883 of file grndclik.cpp.

00884 {
00885     // Get a DIB out of the CCMalloc heap
00886     LPBITMAPINFO bmInfo = NULL;
00887     bmInfo = AllocDIB( Width, Height, Depth, lplpBits, NULL, FALSE);
00888 
00889     // return it.
00890     return bmInfo;
00891 }

BOOL GRenderClick::GetNextBand  )  [virtual]
 

Since this class does not do banded rendering, there are never any more bands.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/5/95
Returns:
FALSE

Reimplemented from GRenderDIB.

Definition at line 862 of file grndclik.cpp.

00863 {
00864     // No banding
00865     return FALSE;
00866 }

BOOL GRenderClick::ImmediateRender  )  [virtual]
 

Used to Draw something immediately.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/03/2004
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if current clip rect is within view (ie whether to render or not).

Errors: -

See also:
-

Reimplemented from RenderRegion.

Definition at line 272 of file grndclik.cpp.

00273 {
00274     RenderFlags.bImmediateRender = TRUE;
00275     if (!StartRender())
00276         return FALSE;
00277 
00278     // Set no funny attributes - let the hit test rendering do all that
00279 
00280     return TRUE;
00281 }

void GRenderClick::SetClean BOOL  bResetChangedBounds,
BOOL  FillWhite
[protected, virtual]
 

Clears out the RR, both logically and (optionally) physically).

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94
Parameters:
FillWhite TRUE for fill with white, FALSE to leave contents alone. [INPUTS]

Reimplemented from GRenderRegion.

Definition at line 296 of file grndclik.cpp.

00297 {
00298     // Do the normal cleaning process
00299     GRenderDIB::SetClean(bResetChangedBounds, FillWhite);
00300 
00301     // and if asked, mark the rr as needing clearing
00302     ClearOnStart = FillWhite;
00303 
00304     // Damn well clear it NOW!
00305     if (ClearOnStart)
00306     {
00307         // Set it to white
00308         if (pBits!=NULL)
00309             memset(pBits, 0xFF, pBitmapInfo->bmiHeader.biSizeImage);
00310         
00311         // Dont do it next time please
00312         ClearOnStart = FALSE;
00313     }
00314 }

BOOL GRenderClick::SetFirstBand  )  [virtual]
 

Sets up for banded rendering. This class does not do banded rendering as yet. This just sets things up to indicate that everything will be done in one band.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/5/95
Returns:
TRUE

Reimplemented from GRenderDIB.

Definition at line 840 of file grndclik.cpp.

00841 {
00842     // No Banding needed
00843     IsRegionBanded = FALSE;
00844     IsWaitingForRAM = FALSE;
00845     IsLastBand = TRUE;
00846     return TRUE;
00847 }

BOOL GRenderClick::StartRender void   )  [protected, virtual]
 

Most work done in base class, except for the calculation of the address & mask of the centre pixel.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/94
Returns:
TRUE if worked, FALSE if failed.

Reimplemented from GRenderRegion.

Reimplemented in GRenderClickColour.

Definition at line 749 of file grndclik.cpp.

00750 {
00751     if (!GRenderDIB::StartRender())
00752         return FALSE;
00753 
00754     // work out the address & mask of the centre pixel
00755     const INT32 w = WRect.width;
00756     const INT32 h = WRect.height;
00757 
00758     // address is pretty easy
00759     pMiddle = pBits + (h/2)*DIBUtil::ScanlineSize( w, 1 );
00760     pMiddle += ((w/2)/8);
00761 
00762     // bit within byte is also reasonably straight-forward (and should be independent of
00763     // byte-sex)
00764     MiddleMask = (BYTE) ( (INT32)0x80 >> ((w/2)&7) );
00765 
00766     // If we have been asked to clear out the contents of the bmp, then do it
00767     if (ClearOnStart)
00768     {
00769         // Set it to white
00770         if (pBits!=NULL)
00771             memset(pBits, 0xFF, pBitmapInfo->bmiHeader.biSizeImage);
00772         
00773         // Dont do it next time please
00774         ClearOnStart = FALSE;
00775     }
00776 
00777     return TRUE;
00778 }


Friends And Related Function Documentation

friend class OSRenderBitmap [friend]
 

Reimplemented in GRenderClickColour, and GRenderClickColourNoPaper.

Definition at line 120 of file grndclik.h.


Member Data Documentation

BOOL GRenderClick::ClearOnStart [protected]
 

Definition at line 151 of file grndclik.h.

BYTE GRenderClick::MiddleMask [protected]
 

Definition at line 148 of file grndclik.h.

LPBYTE GRenderClick::pMiddle [protected]
 

Definition at line 147 of file grndclik.h.


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