CNamedColourReplacer Class Reference

This is a somewhat specialised class whose purpose is to temporarily replace the Named colours in a ColourFillAttribute. Its stores the colours that are replaced and can be called upon to put them back at a later time. It was designed for use with the Brush attribute, where we wish to be able to replace named colours in the brush objects, and then change them back. If you can think of any other uses for it then feel free. More...

#include <cnamecol.h>

Inheritance diagram for CNamedColourReplacer:

CCObject SimpleCCObject CHSVChanger List of all members.

Public Member Functions

 CNamedColourReplacer ()
 Constructor.
 CNamedColourReplacer (ColourFillAttribute *, DocColour *)
 Constructor with initialisation.
 ~CNamedColourReplacer ()
 Destructor.
virtual BOOL Initialise (ColourFillAttribute *, DocColour *)
 initialisation function.
virtual BOOL IsInitialised ()
 as above
virtual BOOL ReplaceColours ()
 This function asks the colour fill for its start colour, checks to see if they are named, or if they were created by a named colour. If so it copies them and stores them. It then replaces them with our replacement colour.
virtual BOOL RestoreColours ()
 This function assumes that ReplaceColours has been previously called. It uses its pointers to start and end colours to set colours in the attribute.
ColourFillAttributeGetColourFill ()
 access fn.
BOOL SetColourFill (ColourFillAttribute *)
 access fn.
DocColourGetReplacementColour ()
 access fn.
BOOL SetReplacementColour (DocColour *)
 access fn.

Protected Attributes

ColourFillAttributem_pColourFill
DocColourm_pReplaceColour
DocColour m_StartColour
DocColour m_EndColour1
DocColour m_EndColour2
DocColour m_EndColour3

Detailed Description

This is a somewhat specialised class whose purpose is to temporarily replace the Named colours in a ColourFillAttribute. Its stores the colours that are replaced and can be called upon to put them back at a later time. It was designed for use with the Brush attribute, where we wish to be able to replace named colours in the brush objects, and then change them back. If you can think of any other uses for it then feel free.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/4/2000

Definition at line 126 of file cnamecol.h.


Constructor & Destructor Documentation

CNamedColourReplacer::CNamedColourReplacer  ) 
 

Constructor.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000

Definition at line 127 of file cnamecol.cpp.

00128 {
00129     m_pColourFill    = NULL;
00130     m_pReplaceColour = NULL;
00131 }

CNamedColourReplacer::CNamedColourReplacer ColourFillAttribute pFillAttr,
DocColour pColour
 

Constructor with initialisation.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
pFillAttr - the attribute value that we want to replace the colours in [INPUTS] pColour - the colour we wish to replace them with

Definition at line 145 of file cnamecol.cpp.

00146 {
00147     // call the default constructor that NULLs all the member pointers
00148     CNamedColourReplacer::CNamedColourReplacer();
00149     Initialise(pFillAttr, pColour);
00150 }

CNamedColourReplacer::~CNamedColourReplacer  ) 
 

Destructor.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000

Definition at line 164 of file cnamecol.cpp.

00165 {
00166 
00167 }


Member Function Documentation

ColourFillAttribute * CNamedColourReplacer::GetColourFill  ) 
 

access fn.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
pointer to the attribute that we are replacing colours in

Definition at line 300 of file cnamecol.cpp.

00301 {
00302     return m_pColourFill;
00303 }

DocColour * CNamedColourReplacer::GetReplacementColour  ) 
 

access fn.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
pointer to the the colour we are using to replace

Definition at line 341 of file cnamecol.cpp.

00342 {
00343     return m_pReplaceColour;
00344 }

BOOL CNamedColourReplacer::Initialise ColourFillAttribute pFillAttr,
DocColour pColour
[virtual]
 

initialisation function.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
pFillAttr - the attribute value that we want to replace the colours in [INPUTS] pColour - the colour we wish to replace them with

Definition at line 181 of file cnamecol.cpp.

00182 {
00183     if (pFillAttr == NULL || pColour == NULL)
00184         return FALSE;
00185 
00186     m_pColourFill = pFillAttr;
00187     m_pReplaceColour = pColour;
00188 
00189     return TRUE;
00190 }

BOOL CNamedColourReplacer::IsInitialised  )  [virtual]
 

as above

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS] Retuns: TRUE if our important members have been initialised, FALSE otherwise

Reimplemented in CHSVChanger.

Definition at line 205 of file cnamecol.cpp.

00206 {
00207     return ((m_pColourFill != NULL) && (m_pReplaceColour != NULL));
00208 }

BOOL CNamedColourReplacer::ReplaceColours  )  [virtual]
 

This function asks the colour fill for its start colour, checks to see if they are named, or if they were created by a named colour. If so it copies them and stores them. It then replaces them with our replacement colour.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
TRUE if all went well, FALSE if something went wrong

Reimplemented in CHSVChanger.

Definition at line 225 of file cnamecol.cpp.

00226 {
00227 //  PORTNOTETRACE("other","CNamedColourReplacer::ReplaceColours - do nothing");
00228 //#ifndef EXCLUDE_FROM_XARALX
00229     if (m_pColourFill == NULL || m_pReplaceColour == NULL)
00230     {
00231         ERROR3("CNamedColourReplacer not initialised correctly");
00232         return FALSE;
00233     }
00234 
00235     // we only replace the start colour, so as to maintain the effect on
00236     // 2/3/4 colour fills
00237     DocColour* pOrigStartCol = m_pColourFill->GetStartColour();
00238     if (pOrigStartCol != NULL && pOrigStartCol->IsNamed())
00239     {
00240         // we've got one, so stash the original and replace it
00241         m_StartColour = *pOrigStartCol;
00242         m_pColourFill->SetStartColour(m_pReplaceColour);
00243         
00244     }
00245 
00246     return TRUE;
00247 //#else
00248 //  return FALSE;
00249 //#endif
00250 }

BOOL CNamedColourReplacer::RestoreColours  )  [virtual]
 

This function assumes that ReplaceColours has been previously called. It uses its pointers to start and end colours to set colours in the attribute.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
- [INPUTS]
Returns:
TRUE if all went well, FALSE if something went wrong

Reimplemented in CHSVChanger.

Definition at line 266 of file cnamecol.cpp.

00267 {
00268 //  PORTNOTETRACE("other","CNamedColourReplacer::RestoreColours - do nothing");
00269 //#ifndef EXCLUDE_FROM_XARALX
00270     if (m_pColourFill == NULL)
00271     {
00272         ERROR3("Colour fill is NULL in CNamedColourReplacer::RestoreColours");
00273         return FALSE;
00274     }
00275 
00276     // restore our colour
00277     if (m_StartColour.GetReservedFlag() == COL_NAMED)
00278         m_pColourFill->SetStartColour(&m_StartColour);
00279     
00280 
00281     return TRUE;
00282 //#else
00283 //  return FALSE;
00284 //#endif
00285 }

BOOL CNamedColourReplacer::SetColourFill ColourFillAttribute pAttr  ) 
 

access fn.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
pAttr - pointer to a colour fill attribute that we wish to replace the colours in [INPUTS]
Returns:
TRUE, unless you pass in a duff pointer

Definition at line 319 of file cnamecol.cpp.

00320 {
00321     if (pAttr == NULL)
00322         return FALSE;
00323     m_pColourFill = pAttr;
00324     return TRUE;
00325 }

BOOL CNamedColourReplacer::SetReplacementColour DocColour pColour  ) 
 

access fn.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/4/2000
Parameters:
pColour - the colour we wish to set in our attribute [INPUTS]
Returns:
TRUE, unless the colour is NULL

Definition at line 359 of file cnamecol.cpp.

00360 {
00361     if (pColour == NULL)
00362         return FALSE;
00363     m_pReplaceColour = pColour;
00364     return TRUE;
00365 }


Member Data Documentation

DocColour CNamedColourReplacer::m_EndColour1 [protected]
 

Definition at line 156 of file cnamecol.h.

DocColour CNamedColourReplacer::m_EndColour2 [protected]
 

Definition at line 157 of file cnamecol.h.

DocColour CNamedColourReplacer::m_EndColour3 [protected]
 

Definition at line 158 of file cnamecol.h.

ColourFillAttribute* CNamedColourReplacer::m_pColourFill [protected]
 

Definition at line 153 of file cnamecol.h.

DocColour* CNamedColourReplacer::m_pReplaceColour [protected]
 

Definition at line 154 of file cnamecol.h.

DocColour CNamedColourReplacer::m_StartColour [protected]
 

Definition at line 155 of file cnamecol.h.


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