TxtRulerAttribute Class Reference

This text attribute specifies the ruler (i.e., tab stops) Conceptually, a ruler is just a pointer to a sorted list of tab stops. More...

#include <txtattr.h>

Inheritance diagram for TxtRulerAttribute:

TxtBaseClassAttribute AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 TxtRulerAttribute ()
 Default Constructor for TxtRulerAttribute Creates an empty tab stops list.
 ~TxtRulerAttribute ()
 Destructor.
virtual void Restore (RenderRegion *, BOOL)
 Restores the TxtRulerAttribute attribute for the given render region.
virtual void Render (RenderRegion *pRegion, BOOL Temp=FALSE)
 Sets the TxtRulerAttribute attribute for the given render region.
virtual void SimpleCopy (AttributeValue *)
 See AttributeValue::SimpleCopy.
virtual NodeAttributeMakeNode ()
 Make a AttrTxtTracking node, see base class.
BOOL IsDifferent (AttributeValue *pAttr)
 See base class version.
virtual TxtRulerAttributeoperator= (TxtRulerAttribute &Attrib)
 Assignment operator.
INT32 operator== (const TxtRulerAttribute &Attrib)
 Comparison operator. See NodeAttribute::operator== for a description of why it's required.
void AddTabStop (TxtTabType Type, MILLIPOINT Position)
 Adds a new tab stop at the given position to the sorted list, removing any other tab stop already present at this position.
void AddTabStop (TxtTabType Type, MILLIPOINT Position, WCHAR DecimalPointChar, WCHAR TabFillerChar)
 Adds a new tab stop at the given position to the sorted list, removing any other tab stop already present at this position.
void AddTabStop (TxtTabStop TabStop)
 Adds a new tab stop at the given position to the sorted list, removing any other tab stop already present at this position.
void FindTabStop (MILLIPOINT MinPos, TxtTabType *pType, MILLIPOINT *pPos, WCHAR *pDecimalPointChar) const
 Finds a tab stop at the given position or higher.
const_TxtTabStopIterator begin () const
const_TxtTabStopIterator end () const
TxtTabStopIterator begin ()
TxtTabStopIterator end ()
INT32 NumTabStops () const

Static Public Member Functions

static BOOL Init ()
 Registers default attribute.
static void FindTabStopInRuler (const TxtRuler *pRuler, MILLIPOINT MinPos, TxtTabType *pType, MILLIPOINT *pPos, WCHAR *pDecimalPointChar)
 Finds a tab stop at the given position or higher.

Public Attributes

TxtRulerValue

Private Member Functions

 TxtRulerAttribute (const TxtRulerAttribute &)

Detailed Description

This text attribute specifies the ruler (i.e., tab stops) Conceptually, a ruler is just a pointer to a sorted list of tab stops.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
13/6/06
See also:
-

Definition at line 642 of file txtattr.h.


Constructor & Destructor Documentation

TxtRulerAttribute::TxtRulerAttribute  ) 
 

Default Constructor for TxtRulerAttribute Creates an empty tab stops list.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
13/06/06

Definition at line 3037 of file txtattr.cpp.

03038 {
03039     Value = new TxtRuler;
03040 } 

TxtRulerAttribute::~TxtRulerAttribute  ) 
 

Destructor.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
13/06/06

Definition at line 3051 of file txtattr.cpp.

03052 {
03053     delete Value;
03054 } 

TxtRulerAttribute::TxtRulerAttribute const TxtRulerAttribute  )  [private]
 


Member Function Documentation

void TxtRulerAttribute::AddTabStop TxtTabStop  TabStop  ) 
 

Adds a new tab stop at the given position to the sorted list, removing any other tab stop already present at this position.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
14/6/06
Parameters:
TabStop - a tab stop to be added [INPUTS]

Definition at line 3068 of file txtattr.cpp.

03069 {
03070     MILLIPOINT Position = TabStop.GetPosition();
03071     TxtTabStopIterator It = begin();
03072     TxtTabStopIterator End = end();
03073     while(It != End)
03074     {
03075         if ((*It).GetPosition() > Position) break;
03076         else if ((*It).GetPosition() == Position)
03077         {
03078             // modify this tab directly
03079             (*It) = TabStop;
03080             return;
03081         }
03082         ++It;
03083     }
03084     Value->insert(It, TabStop);
03085 }

void TxtRulerAttribute::AddTabStop TxtTabType  Type,
MILLIPOINT  Position,
WCHAR  DecimalPointChar,
WCHAR  TabFillerChar
 

Adds a new tab stop at the given position to the sorted list, removing any other tab stop already present at this position.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
14/6/06
Parameters:
Type,Position,DecimalPointChar,TabFillerChar - the parameters for the tab stop [INPUTS]

Definition at line 3130 of file txtattr.cpp.

03131 {
03132     TxtTabStopIterator It = begin();
03133     TxtTabStopIterator End = end();
03134     while(It != End)
03135     {
03136         if ((*It).GetPosition() > Position) break;
03137         else if ((*It).GetPosition() == Position)
03138         {
03139             // modify this tab directly
03140             *It = TxtTabStop(Type, Position, DecimalPointChar, TabFillerChar);
03141             return;
03142         }
03143         ++It;
03144     }
03145     Value->insert(It, TxtTabStop(Type, Position, DecimalPointChar, TabFillerChar));
03146 }

void TxtRulerAttribute::AddTabStop TxtTabType  Type,
MILLIPOINT  Position
 

Adds a new tab stop at the given position to the sorted list, removing any other tab stop already present at this position.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
14/6/06
Parameters:
Type,Position - the parameters for the tab stop [INPUTS]

Definition at line 3100 of file txtattr.cpp.

03101 {
03102     TxtTabStopIterator It = begin();
03103     TxtTabStopIterator End = end();
03104     while(It != End)
03105     {
03106         if ((*It).GetPosition() > Position) break;
03107         else if ((*It).GetPosition() == Position)
03108         {
03109             // modify this tab directly
03110             (*It).SetType(Type);
03111             return;
03112         }
03113         ++It;
03114     }
03115     Value->insert(It, TxtTabStop(Type, Position));
03116 }

TxtTabStopIterator TxtRulerAttribute::begin  )  [inline]
 

Definition at line 668 of file txtattr.h.

00668 { return Value->begin(); }

const_TxtTabStopIterator TxtRulerAttribute::begin  )  const [inline]
 

Definition at line 666 of file txtattr.h.

00666 { return Value->begin(); }

TxtTabStopIterator TxtRulerAttribute::end  )  [inline]
 

Definition at line 669 of file txtattr.h.

00669 { return Value->end(); }

const_TxtTabStopIterator TxtRulerAttribute::end  )  const [inline]
 

Definition at line 667 of file txtattr.h.

00667 { return Value->end(); }

void TxtRulerAttribute::FindTabStop MILLIPOINT  MinPos,
TxtTabType pType,
MILLIPOINT pPos,
WCHAR pDecimalPointChar
const
 

Finds a tab stop at the given position or higher.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
21/6/06
Parameters:
MinPos - minimum position of the tab stop [INPUTS]
stores the tab stop's type in pType, its position in pPos and its decimal point [OUTPUTS] character in pDecimalPointChar (if applicable, else undefined)

Definition at line 3161 of file txtattr.cpp.

03163 {
03164     FindTabStopInRuler(Value, MinPos, pType, pPos, pDecimalPointChar);
03165 }

void TxtRulerAttribute::FindTabStopInRuler const TxtRuler pRuler,
MILLIPOINT  MinPos,
TxtTabType pType,
MILLIPOINT pPos,
WCHAR pDecimalPointChar
[static]
 

Finds a tab stop at the given position or higher.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
21/6/06
Parameters:
pRuler - the ruler list or NULL [INPUTS] MinPos - minimum position of the tab stop
stores the tab stop's type in pType, its position in pPos and its decimal point [OUTPUTS] character in pDecimalPointChar (if applicable, else undefined)

Definition at line 3181 of file txtattr.cpp.

03183 {
03184     // we cope with pRuler being NULL, in which case we simply treat it as empty
03185     if (pRuler)
03186     {
03187         for(const_TxtTabStopIterator It = pRuler->begin() ; It != pRuler->end(); ++It)
03188         {
03189             // NB - we must find a tab stop *beyond* our current position, we cannot
03190             //      take the one exactly at our position - otherwise, having a tab
03191             //      directly after a tab would not advance to the next tab stop
03192             if ((*It).GetPosition() > MinPos) {
03193                 *pType = (*It).GetType();
03194                 *pPos  = (*It).GetPosition();
03195                 if ((*It).GetType() == DecimalTab)
03196                     *pDecimalPointChar = (*It).GetDecimalPointChar();
03197                 return;
03198             }
03199         }
03200     }
03201     // we did not find any tab stop beyond our position, so assume equidistant left tabs
03202     // at each multiple of 0.5in (this is what OpenOffice does)
03203     *pType = LeftTab;
03204     *pPos  = MinPos + 36000 - (MinPos % 36000);
03205 }

BOOL TxtRulerAttribute::Init void   )  [static]
 

Registers default attribute.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Returns:
TRUE - initialised ok; FALSE if not.

Errors: Out of memory.

See also:
AttributeManager

Reimplemented from SimpleCCObject.

Definition at line 3450 of file txtattr.cpp.

03451 {
03452     TxtRulerAttribute *pAttr = new TxtRulerAttribute;
03453     if (pAttr==NULL)
03454         // error message has already been set by new
03455         return FALSE;
03456 
03457     // The default ruler attribute is an empty ruler, so we need not do anything
03458     // here. There are implicit left align tab stops at multiples of 0.5in beyond
03459     // the last user-defined tab stop, so tabs always have an effect.
03460 #if 0
03461 PORTNOTE("text","Just for testing, add a tab stop of each type")
03462     // To test the various tab stop types without requiring a user interface for
03463     // setting tab stops, simply enable this code section
03464     pAttr->AddTabStop(LeftTab, 80000);
03465     pAttr->AddTabStop(CentreTab, 160000);
03466     pAttr->AddTabStop(RightTab, 280000);
03467     pAttr->AddTabStop(DecimalTab, 300000);
03468 #endif
03469     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(BaseTextClass), 
03470                                                          pAttr);
03471 
03472     ERROR2IF(ID == ATTR_BAD_ID, FALSE, "Bad ID when Initialising TxtRulerAttribute");
03473 
03474     return TRUE;
03475 }

BOOL TxtRulerAttribute::IsDifferent AttributeValue pAttr  )  [virtual]
 

See base class version.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Returns:
Errors: The two attributes are not of the same type.
See also:
AttributeValue::IsDifferent

Reimplemented from AttributeValue.

Definition at line 3427 of file txtattr.cpp.

03428 {
03429     // This must be at least a FillGeometryAttribute...
03430     ERROR3IF(!pAttr->IsKindOf(CC_RUNTIME_CLASS(TxtRulerAttribute)), 
03431                 "Different attribute types in TxtRulerAttribute::IsDifferent()");
03432 
03433     // Check they are NOT the same.
03434     return ( !(*((TxtRulerAttribute *)pAttr) == *this) ); 
03435 }

NodeAttribute * TxtRulerAttribute::MakeNode  )  [virtual]
 

Make a AttrTxtTracking node, see base class.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Returns:
Pointer to the new node, or NULL if out of memory.

Errors: Out of memory

See also:
AttributeValue::MakeNode

Reimplemented from AttributeValue.

Definition at line 3490 of file txtattr.cpp.

03491 {
03492     // Create new attribute node
03493     AttrTxtRuler*  pAttr = new AttrTxtRuler();
03494     if (pAttr==NULL)      
03495         // error message has already been set by new
03496         return NULL;
03497 
03498     // Copy attribute value into the new node.
03499     pAttr->Value.SimpleCopy(this);
03500 
03501     // Return the new node
03502     return pAttr;
03503 }

INT32 TxtRulerAttribute::NumTabStops  )  const [inline]
 

Definition at line 670 of file txtattr.h.

00670 { return Value->size(); }

TxtRulerAttribute & TxtRulerAttribute::operator= TxtRulerAttribute Attrib  )  [virtual]
 

Assignment operator.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
19/06/06
Parameters:
Attrib - the attribute to copy [INPUTS]

Definition at line 3253 of file txtattr.cpp.

03254 {
03255     *Value = *Attrib.Value;  // use TxtRuler's assignment operator (list template class)
03256     return *this;
03257 }

INT32 TxtRulerAttribute::operator== const TxtRulerAttribute Attrib  ) 
 

Comparison operator. See NodeAttribute::operator== for a description of why it's required.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
14/6/06
Parameters:
Attrib - the attribute to compare this attribute with [INPUTS]
Returns:
Usual semantics for equality.
See also:
NodeAttribute::operator==

Definition at line 3375 of file txtattr.cpp.

03376 {
03377     // we simply step through both rulers and return FALSE if we find any mismatches
03378     const_TxtTabStopIterator ThisEnd = end();
03379     const_TxtTabStopIterator ThatEnd = Attrib.end();
03380     const_TxtTabStopIterator ThisIt = begin();
03381     const_TxtTabStopIterator ThatIt = Attrib.begin();
03382     for (; ThisIt != ThisEnd || ThatIt != ThatEnd; ++ThisIt, ++ThatIt)
03383     {
03384         // at least one of the iterators still points to a valid tab stop
03385         // so, if either is past the end the rulers are different
03386         if (ThisIt == ThisEnd || ThatIt == ThatEnd) return FALSE;
03387         TxtTabStop ThisStop = *ThisIt;
03388         TxtTabStop ThatStop = *ThatIt;
03389         // both iterators valid, so compare the tab stops
03390         if (ThisStop != ThatStop) return FALSE;
03391     }
03392     return TRUE;
03393 }

void TxtRulerAttribute::Render RenderRegion pRegion,
BOOL  Temp = FALSE
[virtual]
 

Sets the TxtRulerAttribute attribute for the given render region.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]

Implements AttributeValue.

Definition at line 3218 of file txtattr.cpp.

03219 {
03220     pRegion->SetTxtRuler(this, Temp);
03221 }

void TxtRulerAttribute::Restore RenderRegion pRegion,
BOOL  Temp
[virtual]
 

Restores the TxtRulerAttribute attribute for the given render region.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Parameters:
pRegion - the render region to restore the attribute into. [INPUTS] Temp - TRUE if this is a temporary attribute, FALSE if it is permanent (e.g. it's in a document tree).
See also:
-

Implements TxtBaseClassAttribute.

Definition at line 3237 of file txtattr.cpp.

03238 {
03239     pRegion->RestoreTxtRuler(this, Temp);
03240 }

void TxtRulerAttribute::SimpleCopy AttributeValue pValue  )  [virtual]
 

See AttributeValue::SimpleCopy.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/03/95
Parameters:
pAttr - pointer to the AttributeValue to copy. [INPUTS]

Implements AttributeValue.

Definition at line 3406 of file txtattr.cpp.

03407 {
03408     ERROR3IF(!IS_A(pValue, TxtRulerAttribute), 
03409         "Invalid Attribute value passed to TxtRulerAttribute::SimpleCopy");
03410     // We may as well just use our assignment operator.
03411     *this = *((TxtRulerAttribute*)pValue);
03412 }


Member Data Documentation

TxtRuler* TxtRulerAttribute::Value
 

Definition at line 678 of file txtattr.h.


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