FormatRegion Class Reference

A FormatRegion is a render region that is used during the formatting of characters. No actual rendering is done; the FormatRegion provides a simple way of managing the attribute stack. More...

#include <nodetxtl.h>

Inheritance diagram for FormatRegion:

RenderRegion ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

BOOL GetCharMetrics (CharMetrics *pCharMetrics, WCHAR ch)
 Get metrics for a given char using the current attributes of the format region.
MILLIPOINT GetCharsKerning (WCHAR chLeft, WCHAR chRight)
 Finds the kerning distance between two chars.
MILLIPOINT GetTracking ()
Justification GetJustification ()
MILLIPOINT GetLineSpacing ()
FIXED16 GetLineSpaceRatio ()
MILLIPOINT GetFontSize ()
MILLIPOINT GetBaseLineShift ()
MILLIPOINT GetLeftMargin ()
MILLIPOINT GetRightMargin ()
MILLIPOINT GetFirstIndent ()
TxtRulerGetRuler ()

Private Member Functions

 FormatRegion ()
 Initialise member variables of the RenderRegion to keep it happy.
 ~FormatRegion ()
 Destructor for FormatRegion.
BOOL Init (NodeRenderableInk *pFirstNode)
 Initialise a FormatRegion setting the attribute stack to those attributes applied to the specified node.
virtual void DrawPathToOutputDevice (Path *PathToRender, PathShape shapePath=PATHSHAPE_PATH)
virtual void DrawRect (DocRect *RectToRender)
virtual void DrawDragRect (DocRect *RectToRender)
virtual void DrawLine (const DocCoord &StartPoint, const DocCoord &EndPoint)
virtual void DrawPixel (const DocCoord &Point)
virtual void DrawBlob (DocCoord p, BlobType type)
virtual void DrawCross (const DocCoord &Point, const UINT32 Size)
virtual void DrawBitmap (const DocCoord &Point, KernelBitmap *pBitmap)
virtual void DrawBitmap (const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID=NULL)
virtual void DrawBitmapBlob (const DocCoord &Point, KernelBitmap *BlobShape)
virtual void DrawBitmapBlob (const DocCoord &Point, ResourceID resID)
virtual void DrawFixedSystemText (StringBase *TheText, DocRect &BoundsRect, UINT32 uFormat=DEFAULT_TEXT_FORMATTING)
 To draw simple text, using the default host-operating-system font. The size and style of this font are decided by the host OS (or oil code) and cannot be set in any way. To determine how much space is needed to display a string with this method, see the SeeAlso.
virtual void SetFixedSystemTextColours (DocColour *TextCol, DocColour *Background)
 To set the text and background colour(s) for any FixedSystem text rendered in this render region in the future (within the current rendering pass).
virtual void GetFixedSystemTextSize (StringBase *TheText, DocRect *BoundsRect, double *atDpi=NULL)
 To determine how much room is needed to plot a bit of text with RenderRegion::DrawFixedSystemText.
virtual void DrawPixelRect (DocRect *RectToRender)
 To try and plot a single pixel rectangle outline. It does this by using filled rectangles rather than just drawing the line itself. This is required because although GDI and GDraw fills can be made to match up, their outlines can't (at the time of writing). Assumes fill colour and line colour have already been set up along with a line width, usually assumed to be zero which means plot single-pixel lines. Usually, the fill colour is set to be the required line colour and the line colour is set to be transparent (COLOUR_TRANS).
virtual void DrawPixelLine (const DocCoord &StartPoint, const DocCoord &EndPoint)
 To try and plot a single pixel line. It does this by using a filled rectangle rather than just drawing the line itself. This is required because although GDI and GDraw fills can be made to match up, their outlines can't (at the time of writing). Assumes fill colour and line colour have already been set up along with a line width, usually assumed to be zero which means plot single-pixel lines. Usually, the fill colour is set to be the required line colour and the line colour is set to be transparent (COLOUR_TRANS).
virtual BOOL StopRender (void)
virtual void InitClipping (void)
virtual void InitAttributes (void)
virtual void SetLineAttributes (void)
virtual void SetOSDrawingMode (void)
virtual void SetQualityLevel (void)
 Does nothing.
virtual INT32 CalcPixelWidth (void)
virtual INT32 CalcScaledPixelWidth (void)

Private Attributes

std::auto_ptr< wxDC > m_pFormatDC

Detailed Description

A FormatRegion is a render region that is used during the formatting of characters. No actual rendering is done; the FormatRegion provides a simple way of managing the attribute stack.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/03/95
Call the init function before using the FormatRegion. This is passed the root node of the subtree to format. The Init function renders all the attributes applied to this node into the FormatRegion. You can then use the object as an attribute stack. You will want to call each nodes Format function. NOTE: you will also want to render all attributes you come across into the FormatRegion

Definition at line 130 of file nodetxtl.h.


Constructor & Destructor Documentation

FormatRegion::FormatRegion  )  [private]
 

Initialise member variables of the RenderRegion to keep it happy.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/03/95

Definition at line 2062 of file nodetxtl.cpp.

02062                            : RenderRegion()
02063 {
02064     CurrentClipRect = DocRect(0,0,0,0);
02065     ScaledPixelWidth = 1;
02066 }

FormatRegion::~FormatRegion  )  [private]
 

Destructor for FormatRegion.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/03/95

Definition at line 2077 of file nodetxtl.cpp.

02078 {
02079 }


Member Function Documentation

virtual INT32 FormatRegion::CalcPixelWidth void   )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 168 of file nodetxtl.h.

00168 {return 1;};

virtual INT32 FormatRegion::CalcScaledPixelWidth void   )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 169 of file nodetxtl.h.

00169 {return 1;};

virtual void FormatRegion::DrawBitmap const DocCoord Point,
UINT32  BitmapID,
UINT32  ToolID = NULL
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 150 of file nodetxtl.h.

00150 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawBitmap const DocCoord Point,
KernelBitmap pBitmap
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 149 of file nodetxtl.h.

00149 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawBitmapBlob const DocCoord Point,
ResourceID  resID
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 152 of file nodetxtl.h.

00152 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawBitmapBlob const DocCoord Point,
KernelBitmap BlobShape
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 151 of file nodetxtl.h.

00151 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawBlob DocCoord  p,
BlobType  type
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 147 of file nodetxtl.h.

00147 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawCross const DocCoord Point,
const UINT32  Size
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 148 of file nodetxtl.h.

00148 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawDragRect DocRect RectToRender  )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 144 of file nodetxtl.h.

00144 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawFixedSystemText StringBase TheText,
DocRect BoundsRect,
UINT32  uFormat = DEFAULT_TEXT_FORMATTING
[inline, private, virtual]
 

To draw simple text, using the default host-operating-system font. The size and style of this font are decided by the host OS (or oil code) and cannot be set in any way. To determine how much space is needed to display a string with this method, see the SeeAlso.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
TheText - The string to render [INPUTS] BoundsRect - Determines where the text is to be plotted. The text will also be clipped within this bounding rectangle if it exceeds the available space.
Notes: THIS BASE CLASS METHOD IS UNSUPPORTED! DO NOT CALL IT! See OSRenderRegion for the supported versions of this method

See also:
OSRenderRegion::DrawFixedSystemText

OSRenderRegion::GetFixedSystemTextSize

Reimplemented from RenderRegion.

Definition at line 155 of file nodetxtl.h.

00155 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawLine const DocCoord StartPoint,
const DocCoord EndPoint
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 145 of file nodetxtl.h.

00145 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawPathToOutputDevice Path PathToRender,
PathShape  shapePath = PATHSHAPE_PATH
[inline, private, virtual]
 

Implements RenderRegion.

Definition at line 142 of file nodetxtl.h.

00142 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawPixel const DocCoord Point  )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 146 of file nodetxtl.h.

00146 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawPixelLine const DocCoord StartPoint,
const DocCoord EndPoint
[inline, private, virtual]
 

To try and plot a single pixel line. It does this by using a filled rectangle rather than just drawing the line itself. This is required because although GDI and GDraw fills can be made to match up, their outlines can't (at the time of writing). Assumes fill colour and line colour have already been set up along with a line width, usually assumed to be zero which means plot single-pixel lines. Usually, the fill colour is set to be the required line colour and the line colour is set to be transparent (COLOUR_TRANS).

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/1/95
Parameters:
StartPoint - The starting point to render from. [INPUTS] EndPoint - The end point to render to.
- [OUTPUTS]
Returns:
-
See also:
OSRenderRegion::DrawLine; GRenderRegion::DrawLine; RenderRegion::DrawPixelRect;

Reimplemented from RenderRegion.

Definition at line 159 of file nodetxtl.h.

00159 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawPixelRect DocRect RectToRender  )  [inline, private, virtual]
 

To try and plot a single pixel rectangle outline. It does this by using filled rectangles rather than just drawing the line itself. This is required because although GDI and GDraw fills can be made to match up, their outlines can't (at the time of writing). Assumes fill colour and line colour have already been set up along with a line width, usually assumed to be zero which means plot single-pixel lines. Usually, the fill colour is set to be the required line colour and the line colour is set to be transparent (COLOUR_TRANS).

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/1/95
Parameters:
RectToRender - The rectangle we wish to render. [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
OSRenderRegion::DrawRect; GRenderRegion::DrawRect; RenderRegion::DrawPixelLine;

Reimplemented from RenderRegion.

Definition at line 158 of file nodetxtl.h.

00158 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::DrawRect DocRect RectToRender  )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 143 of file nodetxtl.h.

00143 {ERROR3("Rendering into a FormatRegion");};

MILLIPOINT FormatRegion::GetBaseLineShift  )  [inline]
 

Definition at line 180 of file nodetxtl.h.

00180 { return RR_TXTBASELINE(); }

BOOL FormatRegion::GetCharMetrics CharMetrics pCharMetrics,
WCHAR  ch
 

Get metrics for a given char using the current attributes of the format region.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/1/96
Parameters:
ch - the character (kern codes should ask for a FONTEMCHAR) [INPUTS]
pCharMetrics - metrics (CharWidth, FontAscent, FontDescent, FontEmWidth) [OUTPUTS]
Returns:
FALSE if fails

Definition at line 2162 of file nodetxtl.cpp.

02163 {
02164     ERROR2IF(pCharMetrics==NULL, FALSE, "FormatRegion::GetCharMetrics() - pCharMetrics==NULL");
02165 
02166     // get the char metrics for the specified character
02167     wxDC               *pDC = m_pFormatDC.get();
02168     CharDescription     FontDesc( FONTEMCHAR, RR_TXTFONTTYPEFACE(), RR_TXTBOLD(), RR_TXTITALIC() );
02169     if( FONTMANAGER->GetCharMetrics( pDC, ch, FontDesc, pCharMetrics ) == FALSE )
02170         return FALSE;
02171 
02172     // get x/y scale factors and apply then to the default metrics found
02173     // Note: y scale factor does not include script ratio so does not affect ascent/descent
02174     //       ie a line of subscript text has the same line ascents/descents as a non-subscript line
02175     TxtScriptAttribute* pScriptAttr=RR_TXTSCRIPT();
02176     ERROR2IF(pScriptAttr==NULL,FALSE,"RenderRegion::GetCharAttributeMatrix() - pScriptAttr==NULL");
02177     double ScaleY = (double)RR_TXTFONTSIZE() / TextManager::GetDefaultHeight();
02178     double ScaleX = ScaleY * RR_TXTASPECTRATIO().MakeDouble() * pScriptAttr->Size.MakeDouble();
02179     pCharMetrics->Scale(ScaleX,ScaleY);
02180 
02181     return TRUE;
02182 }

MILLIPOINT FormatRegion::GetCharsKerning WCHAR  chLeft,
WCHAR  chRight
 

Finds the kerning distance between two chars.

Author:
Jonathan_Payne (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/10/2000
Parameters:
chLeft - the left char of a kern pair [INPUTS] chRight - the right char of a kern pair
Returns:
Kern distance between chars or 0 on error or no kern

Definition at line 2196 of file nodetxtl.cpp.

02197 {
02198     // get the char metrics for the specified character
02199     wxDC               *pDC = m_pFormatDC.get();
02200     CharDescription     FontDesc(FONTEMCHAR, RR_TXTFONTTYPEFACE(), RR_TXTBOLD(), RR_TXTITALIC());
02201     MILLIPOINT          kern = FONTMANAGER->GetCharsKerning( pDC, chLeft, chRight, FontDesc );
02202 
02203     // get x/y scale factors and apply then to the default metrics found
02204     // Note: y scale factor does not include script ratio so does not affect ascent/descent
02205     //       ie a line of subscript text has the same line ascents/descents as a non-subscript line
02206     TxtScriptAttribute* pScriptAttr=RR_TXTSCRIPT();
02207     ERROR2IF(pScriptAttr==NULL,FALSE,"RenderRegion::GetCharAttributeMatrix() - pScriptAttr==NULL");
02208     double ScaleY = (double)RR_TXTFONTSIZE() / TextManager::GetDefaultHeight();
02209     double ScaleX = ScaleY * RR_TXTASPECTRATIO().MakeDouble() * pScriptAttr->Size.MakeDouble();
02210 
02211     if (kern)
02212         kern = (MILLIPOINT)(kern * ScaleX + 0.5);
02213 
02214     return kern;
02215 }

MILLIPOINT FormatRegion::GetFirstIndent  )  [inline]
 

Definition at line 183 of file nodetxtl.h.

00183 { return RR_TXTFIRSTINDENT(); }

virtual void FormatRegion::GetFixedSystemTextSize StringBase TheText,
DocRect BoundsRect,
double *  atDpi = NULL
[inline, private, virtual]
 

To determine how much room is needed to plot a bit of text with RenderRegion::DrawFixedSystemText.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
TheText - The string to get the rendered size of [INPUTS]
BoundsRect - Returned with the size of the rectangle needed to display [OUTPUTS] said text string. This rect always has one corner at (0,0)
Returns:
-
Notes: THIS BASE CLASS METHOD IS UNSUPPORTED! DO NOT CALL IT! See OSRenderRegion for the supported versions of this method

See also:
OSRenderRegion::DrawFixedSystemText

OSRenderRegion::GetFixedSystemTextSize

Reimplemented from RenderRegion.

Definition at line 157 of file nodetxtl.h.

00157 {ERROR3("Rendering into a FormatRegion");};

MILLIPOINT FormatRegion::GetFontSize  )  [inline]
 

Definition at line 179 of file nodetxtl.h.

00179 { return RR_TXTFONTSIZE(); }

Justification FormatRegion::GetJustification  )  [inline]
 

Definition at line 176 of file nodetxtl.h.

00176 { return RR_TXTJUSTIFICATION(); }

MILLIPOINT FormatRegion::GetLeftMargin  )  [inline]
 

Definition at line 181 of file nodetxtl.h.

00181 { return RR_TXTLEFTMARGIN(); }

FIXED16 FormatRegion::GetLineSpaceRatio  )  [inline]
 

Definition at line 178 of file nodetxtl.h.

00178 { return ((TxtLineSpaceAttribute*)CurrentAttrs[ATTR_TXTLINESPACE].pAttr)->Ratio; }

MILLIPOINT FormatRegion::GetLineSpacing  )  [inline]
 

Definition at line 177 of file nodetxtl.h.

00177 { return RR_TXTLINESPACE(); }

MILLIPOINT FormatRegion::GetRightMargin  )  [inline]
 

Definition at line 182 of file nodetxtl.h.

00182 { return RR_TXTRIGHTMARGIN(); }

TxtRuler* FormatRegion::GetRuler  )  [inline]
 

Definition at line 184 of file nodetxtl.h.

00184 { return RR_TXTRULER(); }

MILLIPOINT FormatRegion::GetTracking  )  [inline]
 

Definition at line 175 of file nodetxtl.h.

00175 { return RR_TXTTRACKING(); }

BOOL FormatRegion::Init NodeRenderableInk pFirstNode  )  [private]
 

Initialise a FormatRegion setting the attribute stack to those attributes applied to the specified node.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/03/95
Parameters:
pFirstNode - pointer to a node whose applied attributes are used to initialise [INPUTS] the FormatRegion's attribute stack
Returns:
FALSE if fails

Definition at line 2094 of file nodetxtl.cpp.

02095 {
02096     m_pFormatDC = std::auto_ptr<wxDC>( new wxMemoryDC );
02097     if( NULL == m_pFormatDC.get() )
02098         ERROR2(FALSE,"FormatRegion::Init() - CreateCompatibleDC() failed");
02099 
02100     RenderView = DocView::GetSelected();
02101 
02102     // If there is not a selected doc view (e.g. because it is a clipboard document),
02103     // try the current view item.
02104     // This should only be an issue when formatting text that's been imported into the clipboard, usually
02105     // as part of an OLE operation
02106     if (RenderView == NULL)
02107     {
02108         RenderView = View::GetCurrent();
02109         if (RenderView == NULL)
02110         {
02111             ERROR3("No view!! Can't format text without a view");
02112             return FALSE;
02113         }
02114 
02115     //  ERROR3IF(RenderView->GetDoc()->IsNotAClipboard(),"No selected doc view yet doc attached to current view is not a clipboard doc.  Is this right?");
02116     }
02117 
02118     // Initialise the render region
02119     StartRender();
02120 
02121     // Get the attributes
02122     if (pFirstNode==NULL)
02123         return TRUE;
02124 
02125     CCAttrMap          *pAttribMap = new CCAttrMap(30);
02126     if (pAttribMap == NULL) return FALSE;
02127 
02128     if (!pFirstNode->FindAppliedAttributes(pAttribMap))
02129     {
02130         delete pAttribMap;
02131         return FALSE;
02132     }
02133 
02134     CCAttrMap::iterator pos = pAttribMap->GetStartPosition();
02135     CCAttrMap::iterator end = pAttribMap->GetEndPosition();
02136     while( pos != end )
02137     {
02138         CCRuntimeClass *pKey;
02139         void           *pVal;
02140         pAttribMap->GetNextAssoc(pos, pKey, pVal);
02141 
02142         ((NodeAttribute*) pVal)->Render(this);
02143     }
02144 
02145     delete pAttribMap;
02146 
02147     return TRUE;
02148 }

virtual void FormatRegion::InitAttributes void   )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 164 of file nodetxtl.h.

00164 {};

virtual void FormatRegion::InitClipping void   )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 163 of file nodetxtl.h.

00163 {};

virtual void FormatRegion::SetFixedSystemTextColours DocColour TextCol,
DocColour Background
[inline, private, virtual]
 

To set the text and background colour(s) for any FixedSystem text rendered in this render region in the future (within the current rendering pass).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/95
Parameters:
TextCol - The foreground (text) colour (may be NULL) [INPUTS] Background - The background colour (may be NULL)
Notes: THIS BASE CLASS METHOD IS UNSUPPORTED! DO NOT CALL IT! See OSRenderRegion for the supported versions of this method

If either of the colours is passed in as a NULL pointer, that colour will not be set, and will remain at the previous setting.

Note that these values are passed directly to the host OS at the point of calling, so you must call this method every time the colour is changed (i.e. don't rely on just changing the DocColours that you passed in originally, as they aren't remembered in any way). Note also that if you call DrawFixedSystemText without a prior call to this method, the colours used are undefined.

See also:
OSRenderRegion::DrawFixedSystemText

Reimplemented from RenderRegion.

Definition at line 156 of file nodetxtl.h.

00156 {ERROR3("Rendering into a FormatRegion");};

virtual void FormatRegion::SetLineAttributes void   )  [inline, private, virtual]
 

Definition at line 165 of file nodetxtl.h.

00165 {};

virtual void FormatRegion::SetOSDrawingMode void   )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 166 of file nodetxtl.h.

00166 {};

virtual void FormatRegion::SetQualityLevel void   )  [inline, private, virtual]
 

Does nothing.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/8/97
Parameters:
- [INPUTS]
This used to be a pure function until we found a way of making the base class get called (due to the introduction of the path processing code)

See also:
RenderRegion::SetQuality

Reimplemented from RenderRegion.

Definition at line 167 of file nodetxtl.h.

00167 {};

virtual BOOL FormatRegion::StopRender void   )  [inline, private, virtual]
 

Implements RenderRegion.

Definition at line 162 of file nodetxtl.h.

00162 {return TRUE;};


Member Data Documentation

std::auto_ptr<wxDC> FormatRegion::m_pFormatDC [private]
 

Definition at line 186 of file nodetxtl.h.


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