Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Canvas Class Reference

The CP_Canvas class is a wrapper class for a platforms graphics port used for drawing into. More...

Inheritance diagram for CP_Canvas:

CP_OffscreenCanvas List of all members.

Public Member Functions

Constructor / Destructor
 CP_Canvas ()
 Constructor.
 CP_Canvas (OSGraphicsPort inGraphicsPort)
 CP_Canvas (const CP_Canvas &inCanvas)
 CP_Canvas (CGContextRef inContextRef)
virtual ~CP_Canvas ()
 Destructor.
Operators
CP_Canvasoperator= (const CP_Canvas &inCanvas)

Protected Attributes

OSGraphicsPort fOSGraphicsPort
bool fIsValid
CGContextRef fContextRef
bool fHasValidContextRef
bool fOwnsContext
bool fUsingQDCoords
CP_FontfFont

Detailed Description

All drawing in CPLAT is done by drawing into some type of CP_Canvas object. There is also a CP_Canvas object that can be used for offscreen drawing.

Note: A CP_Canvas object does not maintain a permanent graphics port, and is only valid during the time that the underlying OS wants to draw some type of information.


Constructor & Destructor Documentation

CP_Canvas::CP_Canvas  ) 
 

Constructor.

Exceptions:
none 

CP_Canvas::CP_Canvas OSGraphicsPort  inGraphicsPort  ) 
 

Constructor.

Parameters:
inGraphicsPort The OSGraphicsPort that we are managing.
Exceptions:
none 

CP_Canvas::CP_Canvas const CP_Canvas inCanvas  ) 
 

Copy constructor.

Parameters:
inCanvas Canvas object to copy data fields from.
Exceptions:
none 

CP_Canvas::CP_Canvas CGContextRef  inContextRef  ) 
 

Constructor. This version sets the port to wrap around a Quartz context ref instead of a QuickDraw port. This allows drawing using Quartz instead of QuickDraw.

Parameters:
inContextRef An OSX Quartz context ref for this port.
Exceptions:
none 

CP_Canvas::~CP_Canvas  )  [virtual]
 

Destructor.

Exceptions:
none 


Member Function Documentation

void CP_Canvas::SetForeColor const CP_RGBColor inForeColor  ) 
 

Sets the foreground/stroke color for this port.

Parameters:
inForeColor The color to set the foreground to.
Exceptions:
NULL exceptions.
Returns:
void

void CP_Canvas::SetBackColor const CP_RGBColor inBackColor  ) 
 

Sets the background/fill color for this port.

Parameters:
inBackColor The color to set the background to.
Exceptions:
none 
Returns:
void

CP_RGBColor CP_Canvas::GetForeColor  ) 
 

Returns the foreground color currently set in this canvas.

Exceptions:
none 
Returns:
CP_RGBColor The current foreground color.

CP_RGBColor CP_Canvas::GetBackColor  ) 
 

Returns the background color currently set in this canvas.

Exceptions:
none 
Returns:
CP_RGBColor The current background color.

virtual bool CP_Canvas::HasValidContextRef  )  [virtual]
 

Flag to indicate if have set the context ref for this object, and it is valid to draw into.

Exceptions:
none 
Returns:
bool True if this canvas has a context ref that is valid, and ready to draw into.

bool CP_Canvas::UsingQDCoords  ) 
 

Flag to indicate if our content ref is currently using QuickDraw coordinates.

Exceptions:
none 
Returns:
bool True if the context ref is using QuickDraw coordinates.

void CP_Canvas::SetUsingQDCoords bool  inUsingQDCoords  ) 
 

Sets the lag to indicate if our content ref is currently using QuickDraw coordinates.

Parameters:
inUsingQDCoords True if the context ref is using QuickDraw coordinates.
Exceptions:
none 

CGContextRef CP_Canvas::GetContextRef bool  inSynchOriginWithPort = true  )  [virtual]
 

Return a CoreGraphics port for our canvas object. NOTE: This only works under OSX.

Parameters:
inSynchOriginWithPort Flag to indicate if the returned CGContextRef should have its coordinates transformed to match QuickDraws.
Exceptions:
none 
Returns:
CGContextRef The returned context ref.

void CP_Canvas::SetContextRef CGContextRef  inContextRef  ) 
 

Sets the context ref to the passed in one. If the passed in context ref is not NULL, the canvas object is marked as having a valid context ref.

Exceptions:
none 
Returns:
void

CP_Font * CP_Canvas::GetFont  ) 
 

Returns a CP_Font object that provides access to the font that is used in this canvas object.

Exceptions:
none 
Returns:
CP_Font CP_Font object describing the font used in this canvas.

void CP_Canvas::SetFontSpec CP_FontSpec inFontSpec  ) 
 

Sets the current font settings from the passed in CP_FontSpec.

Parameters:
inFontSpec Describes the appearance of the font, and how drawing will take place in the current canvas.
Exceptions:
none 
Returns:
void

SInt16 CP_Canvas::GetBitDepth  ) 
 

Returns the bit depth of this canvas.

Exceptions:
none 
Returns:
SInt16 The bit depth of the canvas.

bool CP_Canvas::IsColor  ) 
 

Returns true if the canvas is capable of drawing in color.

Exceptions:
none 
Returns:
bool True if this is a color canvas.

OSGraphicsPort CP_Canvas::GetOSPort  ) 
 

Returns the platforms native graphics port

Exceptions:
none 
Returns:
OSGraphicsPort A platforms native graphics port.

void CP_Canvas::SetOSPort OSGraphicsPort  inOSGraphicsPort  ) 
 

Sets the graphics port for this object to that of the passed in platforms graphics port.

Parameters:
inOSGraphicsPort The underlying OS graphics port.
Exceptions:
none 
Returns:
void

CP_Canvas & CP_Canvas::operator= const CP_Canvas inCanvas  ) 
 

Assignment operator.

Parameters:
inCanvas Canvas object to copy data fields from.
Exceptions:
none 
Returns:
CP_Canvas& Returns a referance to ourselves.

void CP_Canvas::SetPenSize SInt16  inSize  ) 
 

Sets the size of the graphics pen for this canvas.

Parameters:
inSize The size of the pen.
Exceptions:
none 
Returns:
void

void CP_Canvas::SetTextMode SInt16  inMode  ) 
 

Sets the text transfer mode used to draw text.

Parameters:
inMode The transfer mode used when text is drawn.
Exceptions:
none 
Returns:
void

bool CP_Canvas::IsValid  )  const
 

Returns true if this canvas object currently holds a valid platforms graphics port to draw into.

Exceptions:
none 
Returns:
bool const


Member Data Documentation

OSGraphicsPort CP_Canvas::fOSGraphicsPort [protected]
 

bool CP_Canvas::fIsValid [protected]
 

A typedefed data member that corresponds to the native graphics port for the OS that CPLAT is running on. It is typedefed in CP_Types.h

CGContextRef CP_Canvas::fContextRef [protected]
 

Flag to indicate if the canvas is currently valid for drawing into.

bool CP_Canvas::fHasValidContextRef [protected]
 

MacOSX Quartz context ref for this port.

bool CP_Canvas::fOwnsContext [protected]
 

Flag to indicate if the context ref is valid.

bool CP_Canvas::fUsingQDCoords [protected]
 

This class created the context ref, and is responsible for its deletion.

CP_Font* CP_Canvas::fFont [protected]
 

The context ref is using QuickDraw coordinates.


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:34 2005 for CPLAT_MacOS by  doxygen 1.4.0