BrushComponent Class Reference

A document component for handling Brush definitions. More...

#include <brshcomp.h>

Inheritance diagram for BrushComponent:

LineComponent DocComponent ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BrushComponent ()
 Constructor.
virtual ~BrushComponent ()
 Destructor.
AttrBrushTypeCreateAttributeNode (BrushHandle Handle)
 

virtual LineHandle AddNewItem (LineDefinition *pLine, BOOL AskName=FALSE)
 Adds the given Line to the global Line list.
BOOL CopyInkObjectsToClipboard (BrushHandle Handle)
 copies the ink objects of this brush definition to the clipboard so they can be used elsewhere
virtual BOOL NameIsUnique (const String_32 &NameString)
 To find out if someone has already gotten this name.
virtual String_32 GetUniqueName (String_32 *pName=NULL)
 When naming a new brush we want to give it the name supplied, however this may well be taken in which case we want to add a number to the default name.
virtual BOOL StartExport (BaseCamelotFilter *pFilter)
 Called before an export is started.
BOOL StartImportBrush (CamelotRecordHandler *pHandler, CXaraFileRecord *pRecord, UINT32 ImportHandle)
 To import a vector Line definition.
BOOL EndImportBrush (CamelotRecordHandler *pHandler)
 To import a vector brush definition.
BOOL ExportLine (BaseCamelotFilter *pFilter, BrushHandle Handle)
 To export a vector Brush definition.
BrushHandle FindImportedBrush (UINT32 ImportedHandle)
 To match up a handle from the currently importing file to the real internal BrushHandle of the imported BrushDefinition.
BrushDefinitionGetImportBrushDefinition ()
 As above, note that this function is only useful in the period between StartImportBrush and EndImportBrush being called. At all other times m_pImportBrushDef should be NULL.
void CleanUpAfterImport ()
 Deletes the objects we created for import. Goes without saying that calling this function before you have added the brushdef to the component is pretty silly.

Static Public Member Functions

static BOOL BeginLoadingDefaultFiles ()
 Lets the component know that we are starting to load default brushes Notes: What happens here is that every brush added to the component whilst m_CurrentDefaultBrush != BRUSHFILE_NONE will be assigned m_CurrentDefaultBrush as its default file ID. Note again, as you can tell from the code this can only be done once.
static BOOL LoadNextDefaultFile ()
 Increments our default file counter.
static void EndLoadingDefaults ()
 Finishes loading default files.
static AttrBrushTypeCreateNode (BrushHandle Handle)
 static version of above
static UINT32 GetNumberOfBrushes ()
static BrushDefinitionFindBrushDefinition (UINT32 Handle, BOOL IncludeDeactivated=FALSE)
static void CancelNewBrush ()
static void SetNewName (String_32 NewName)

Private Member Functions

virtual BOOL ExpandArray (void)
 (Internal method) Expands the storage structure of the Brush list to allow more entries to be used. Called automatically by AddNewBrush as necessary.

Private Attributes

BrushDefinitionm_pImportBrushDef
MILLIPOINT m_StoreSpacing
BOOL m_StoreTile
BOOL m_StoreRotate
double m_StoreRotateAngle
PathOffset m_StorePathOffsetType
MILLIPOINT m_StoreOffsetValue

Static Private Attributes

static String_32 m_NewName = TEXT("Unnamed brush")
static BOOL m_bCancelNewBrush = FALSE
static UINT32 m_CurrentDefaultFile = BRUSHFILE_NONE

Detailed Description

A document component for handling Brush definitions.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/97
BrushComponents share a global cache of available Brush types. Individual instances serve as managers for the list, mainly providing import/export facilities for Brush definitions.

See also:
DocComponent

Definition at line 503 of file brshcomp.h.


Constructor & Destructor Documentation

BrushComponent::BrushComponent  ) 
 

Constructor.

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

Definition at line 3730 of file brshcomp.cpp.

03730                                : LineComponent()
03731 {
03732     m_pImportBrushDef = NULL;
03733     
03734 }

BrushComponent::~BrushComponent  )  [virtual]
 

Destructor.

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

Definition at line 3749 of file brshcomp.cpp.

03750 {
03751     if (m_pImportBrushDef != NULL)
03752         delete m_pImportBrushDef;
03753 }


Member Function Documentation

LineHandle BrushComponent::AddNewItem LineDefinition pItem,
BOOL  AskName = FALSE
[virtual]
 

Adds the given Line to the global Line list.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
pLine - (may not be NULL) A Line definition to add, which now [INPUTS] belongs to the LineComponent, so you mustn't delete it! AskName - a flag saying whether or not we should prompt the user for a name, defaults to FALSE
Returns:
A handle which uniquely identifies the new Line, or LineHandle_NoLine if we ran out of memory for storing Lines
Notes: Also read the notes in LineComponent::AddNewItem This function overrides the base class but actually uses it to do the actual adding. functinality added here is that it works out whether or not the brush has actually been added and if so adds it to the line gallery

Reimplemented from LineComponent.

Definition at line 4458 of file brshcomp.cpp.

04459 {
04460     // just make sure its the right type
04461     ERROR2IF(!pItem->IsKindOf(CC_RUNTIME_CLASS(BrushDefinition)), 
04462             BrushHandle_NoBrush, "Attempting to pass in wrong definition");
04463     String_32 DefaultName(_R(IDS_BRUSH_DEFAULT_NAME));
04464     m_NewName = DefaultName;
04465     m_bCancelNewBrush = FALSE;
04466     if (AskName == TRUE)
04467     {
04468         // launch the naming dialog, it will either set m_NewName or tell us to cancel
04469         OpDescriptor* pDesc = OpDescriptor::FindOpDescriptor( OPTOKEN_INITNAME_BRUSH_DLG );
04470         if (pDesc != NULL)
04471         {
04472             pDesc->Invoke();
04473         }
04474     
04475         // did they cancel it?
04476         if (m_bCancelNewBrush)
04477         {
04478             m_bCancelNewBrush = FALSE;
04479             return BrushHandle_NoBrush;
04480         }
04481         
04482         pItem->SetLineName(&m_NewName);
04483     }
04484 
04485     // stash the old number of brushes, which will be incremented if we make a new one
04486     UINT32 OldNumBrushes = m_Used;
04487 
04488     // item is added in the base class
04489     LineHandle NewHandle = LineComponent::AddNewItem(pItem);
04490  
04491     // have we actually added a new brush?
04492     if (NewHandle >= OldNumBrushes && NewHandle != BrushHandle_NoBrush)
04493     {       
04494         // tell it the filename ID
04495         ((BrushDefinition*)pItem)->SetBrushFileID(m_CurrentDefaultFile);
04496 
04497         // make a new atttibute to add to the line gallery
04498         PathProcessorBrush* pNewPathProc = new PathProcessorBrush;
04499         if (pNewPathProc == NULL)
04500         {
04501             ERROR3("Failed to allocate path processor");
04502             return NewHandle;
04503         }
04504 
04505         // tell it which brush definition to use
04506         pNewPathProc->SetBrushDefinition(NewHandle);
04507 
04508         // transfer all the data
04509         ((BrushDefinition*)pItem)->CopyDataToProcessor(pNewPathProc);
04510         // make a new attribute value for use by the line gallery
04511         BrushAttrValue* pVal = new BrushAttrValue(pNewPathProc);
04512         if (pVal == NULL)
04513         {
04514             ERROR3("Unable to allocate new BrushAttrVal");
04515             return NewHandle;
04516         }
04517     
04518         // add it to the line gallery
04519         LineGallery::AddNewBrushItem(pVal); 
04520 
04521         // get the freehand tool
04522         ToolListItem* pToolItem = Tool::Find(TOOLID_FREEHAND);
04523         ERROR2IF(pToolItem == NULL, NewHandle, "Unable to get tool item in DeactivateBrushDefAction::Init");
04524 
04525         FreeHandTool* pTool = (FreeHandTool*)pToolItem->m_pTool;
04526         ERROR2IF(pTool == NULL, NewHandle, "Unable to get tool in DeactivateBrushDefAction::Init");
04527         
04528         // get the infobar
04529         FreeHandInfoBarOp* pInfoBar = ((FreeHandTool*)pTool)->GetInfoBar();
04530         ERROR2IF(pInfoBar == NULL, NewHandle, "Unable to get InfoBar in DeactivateBrushDefAction::Init");
04531 
04532         // add to the freehand infobar
04533         pInfoBar->AddBrush(NewHandle);
04534     }
04535     return NewHandle;
04536 }

BOOL BrushComponent::BeginLoadingDefaultFiles  )  [static]
 

Lets the component know that we are starting to load default brushes Notes: What happens here is that every brush added to the component whilst m_CurrentDefaultBrush != BRUSHFILE_NONE will be assigned m_CurrentDefaultBrush as its default file ID. Note again, as you can tell from the code this can only be done once.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
- [INPUTS]
Returns:
TRUE

Definition at line 3771 of file brshcomp.cpp.

03772 {
03773     m_CurrentDefaultFile = BRUSHFILE_NONE;
03774     return TRUE;
03775 }

void BrushComponent::CancelNewBrush  )  [static]
 

Definition at line 4663 of file brshcomp.cpp.

04664 {
04665     m_bCancelNewBrush = TRUE;
04666 }

void BrushComponent::CleanUpAfterImport  ) 
 

Deletes the objects we created for import. Goes without saying that calling this function before you have added the brushdef to the component is pretty silly.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
- [INPUTS]
Returns:
-

Definition at line 4344 of file brshcomp.cpp.

04345 {
04346     // don't delete the brushdef as it is now being used in the component
04347     if (m_pImportBrushDef != NULL)
04348          m_pImportBrushDef = NULL;
04349 
04350     if (m_pImportNewLine != NULL)
04351         m_pImportNewLine = NULL;
04352 }

BOOL BrushComponent::CopyInkObjectsToClipboard BrushHandle  Handle  ) 
 

copies the ink objects of this brush definition to the clipboard so they can be used elsewhere

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
Handle to the brush definition which we want to send to the clipboard [INPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
-

Definition at line 3875 of file brshcomp.cpp.

03876 {
03877     if (Handle == BrushHandle_NoBrush || Handle >= m_Used)
03878     {
03879         ERROR3("Invalid brush handle");
03880         return FALSE;
03881     }
03882 
03883     BrushDefinition* pBrushDef = (BrushDefinition*)m_pLineArray[Handle];
03884     if (pBrushDef == NULL)
03885     {
03886         ERROR3("Brush definition is NULL");
03887         return FALSE;
03888     }
03889     
03890     return pBrushDef->CopyInkTreeToClipboard();
03891 }

AttrBrushType * BrushComponent::CreateAttributeNode BrushHandle  Handle  ) 
 

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
Handle to the brush definition which we want to base this brush on [INPUTS]
Returns:
Attribute node based on this definition
See also:
-

Definition at line 3835 of file brshcomp.cpp.

03836 {
03837     BrushDefinition* pBrushDef = FindBrushDefinition(Handle);
03838     if (pBrushDef == NULL)
03839         return NULL;
03840 
03841     AttrBrushType* pNewNode = new AttrBrushType;
03842     if (pNewNode == NULL)
03843         return NULL;
03844 
03845     BrushAttrValue* pVal = (BrushAttrValue*)pNewNode->GetAttributeValue();
03846     if (pVal == NULL)
03847         return NULL;
03848 
03849     PathProcessorBrush* pPathProc = new PathProcessorBrush;
03850     if (pPathProc == NULL)
03851         return NULL;
03852     pBrushDef->CopyDataToProcessor(pPathProc);
03853     pVal->SetPathProcessor(pPathProc);
03854 
03855     // tell it which brush definition to use
03856     pPathProc->SetBrushDefinition(Handle);
03857     return pNewNode;
03858 }

AttrBrushType * BrushComponent::CreateNode BrushHandle  Handle  )  [static]
 

static version of above

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
Handle to the brush definition which we want to base this brush on [INPUTS]
Returns:
Attribute node based on this definition
See also:
-

Definition at line 3906 of file brshcomp.cpp.

03907 {
03908     BrushDefinition* pBrushDef = FindBrushDefinition(Handle);
03909     if (pBrushDef == NULL)
03910         return NULL;
03911 
03912     AttrBrushType* pNewNode = new AttrBrushType;
03913     if (pNewNode == NULL)
03914         return NULL;
03915 
03916     BrushAttrValue* pVal = (BrushAttrValue*)pNewNode->GetAttributeValue();
03917     if (pVal == NULL)
03918         return NULL;
03919 
03920     PathProcessorBrush* pPathProc = new PathProcessorBrush;
03921     if (pPathProc == NULL)
03922         return NULL;
03923     pBrushDef->CopyDataToProcessor(pPathProc);
03924     pVal->SetPathProcessor(pPathProc);
03925 
03926     // tell it which brush definition to use
03927     pPathProc->SetBrushDefinition(Handle);
03928     return pNewNode;
03929 }

BOOL BrushComponent::EndImportBrush CamelotRecordHandler pHandler  ) 
 

To import a vector brush definition.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
pRecord - The TAG_BRUSHDEFINITION record to import [INPUTS]
Returns:
TRUE if Import was successful

Definition at line 4081 of file brshcomp.cpp.

04082 {
04083     ERROR2IF(m_pImportPreviousContext == NULL,FALSE, "EndImportBrush - something hasn't gone too well");
04084     ERROR2IF(m_pImportBrushDef == NULL, FALSE, "ImportBrushDef is NULL at EndImportBrush");
04085     
04086     // Restore the previous import context node
04087     pHandler->RestoreInsertContext(m_pImportPreviousContext);
04088     delete m_pImportPreviousContext;
04089     m_pImportPreviousContext = NULL;
04090 
04091     // --- Now, convert all IndexedColours (which are document-dependent) into standalone DocColours
04092     // This wouldn't be necessary, except that the DocColours we saved have magically been turned
04093     // back into local Indexedcolours by the export/import process.
04094     // BLOCK
04095 
04096     LineDefinition::ConvertIndexedColours((Spread*)m_pImportNewLine);
04097 
04098     // Create a new Brush definition from the imported brush    
04099     if (m_pImportBrushDef->GenerateBrush() != TRUE)
04100         return FALSE;
04101     
04102     m_pImportBrushDef->CalculateMaxScaling();
04103 
04104     // add the item,
04105     /*BrushHandle NewHandle =*/ AddNewItem(m_pImportBrushDef); 
04106 
04107     CleanUpAfterImport();
04108 
04109     return TRUE;
04110     
04111     
04112 }

void BrushComponent::EndLoadingDefaults  )  [static]
 

Finishes loading default files.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
- [INPUTS]
Returns:
-
See also:
-

Definition at line 3817 of file brshcomp.cpp.

03818 {
03819     m_CurrentDefaultFile = BRUSHFILE_NONE;
03820 }

BOOL BrushComponent::ExpandArray void   )  [private, virtual]
 

(Internal method) Expands the storage structure of the Brush list to allow more entries to be used. Called automatically by AddNewBrush as necessary.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/2/97
Parameters:
On succesful exit, the member array of BrushDefinition pointers will be bigger [OUTPUTS]
Returns:
FALSE if it failed to allocate memory
Notes: Internal storage is an array of pointers to BrushDefinitions NULL pointers beyond (& including) "Used" indicate free slots. NULL pointers before "Used" indicate deleted Brushs - these slots should NOT be re-used, as there may still be references to them in the system.

Implements LineComponent.

Definition at line 4268 of file brshcomp.cpp.

04269 {
04270     // ****!!!!TODO - if we're multi-threading, this probably needs to be a critical section
04271     // because the list is global
04272     
04273     const INT32 AllocSize = m_CurrentSize + 64;
04274 
04275     if (m_pLineArray == NULL)
04276     {
04277         m_pLineArray = (LineDefinition **) CCMalloc(AllocSize * sizeof(LineDefinition *));
04278         if (m_pLineArray == NULL)
04279             return(FALSE);
04280     }
04281     else
04282     {
04283         // We have an array - we must make it larger
04284         LineDefinition **pNewBuf = (LineDefinition **)
04285                                     CCRealloc(m_pLineArray, AllocSize * sizeof(LineDefinition *));
04286         if (pNewBuf == NULL)
04287             return(FALSE);
04288 
04289         m_pLineArray = pNewBuf;
04290     }
04291 
04292     // Success. Initalise all the new pointers to NULL
04293     for (UINT32 i = m_Used; i < m_CurrentSize; i++)
04294             m_pLineArray[i] = NULL;
04295 
04296     // Update the current size value, and return success
04297     m_CurrentSize = (UINT32)AllocSize;
04298     return(TRUE);
04299     
04300 
04301 }

BOOL BrushComponent::ExportLine BaseCamelotFilter pFilter,
BrushHandle  Handle
[virtual]
 

To export a vector Brush definition.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/99
Parameters:
pFilter - the BaseCamelotFilter filter that is being used to export a file. [INPUTS] Handle - The Brush to be exported
Returns:
TRUE if export was successful FALSE if export was aborted - no error is set, as in this case, it usually means that the Brush has been deleted, and is being treated as an old-style line. In this case, the caller should simply not bother exporting the attribute using the Brush definition.
Notes: Brush definitions (like colours) are only saved out when a node in the tree is found which makes use of the Brush. You should call this function before exporting any attribute which uses the Brush definition. It automatically checks if the Brush has already been saved, and will not save the definition more than once.

When saving your reference to the Brush, save out the Brush's Handle as it's unique ID word.

Implements LineComponent.

Definition at line 4148 of file brshcomp.cpp.

04149 {
04150     ERROR3IF(pFilter == NULL, "Illegal NULL params");
04151 
04152     // Find the stroke, and baulk if it's all gone wrong
04153     BrushDefinition *pBrush = FindBrushDefinition(Handle);
04154     if (pBrush == NULL)
04155     {
04156         ERROR3("Attempt to save a deleted or non-existent stroke");
04157         return(FALSE);
04158     }
04159 
04160     // Check if the definition has already been saved, in which case we don't need to do anything more
04161     if (pBrush->ReadIOStore())
04162         return(TRUE);
04163 
04164     // We've got a stroke definition now, get it to write itself to the file
04165     return pBrush->ExportBrush(pFilter, Handle);
04166     
04167 }

static BrushDefinition* BrushComponent::FindBrushDefinition UINT32  Handle,
BOOL  IncludeDeactivated = FALSE
[static]
 

BrushHandle BrushComponent::FindImportedBrush UINT32  ImportedHandle  ) 
 

To match up a handle from the currently importing file to the real internal BrushHandle of the imported BrushDefinition.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/99
Parameters:
Importedhandle - The handle which is used in the file being imported [INPUTS] to reference the stroke.
Returns:
The BrushHandle of the loaded stroke, or BrushHandle_NoBrush if the stroke could not be found.

Definition at line 4188 of file brshcomp.cpp.

04189 {
04190     ImportedHandle &= 0x00ffffff;   // Only the bottom 24 bits are relevant
04191     for (UINT32 Index = 0; Index < m_Used; Index++)
04192     {
04193         if (m_pLineArray[Index] != NULL && m_pLineArray[Index]->ReadIOStore() == ImportedHandle)
04194             return((BrushHandle)Index);
04195     }
04196 
04197     return(BrushHandle_NoBrush);
04198 }

BrushDefinition * BrushComponent::GetImportBrushDefinition  ) 
 

As above, note that this function is only useful in the period between StartImportBrush and EndImportBrush being called. At all other times m_pImportBrushDef should be NULL.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
- [INPUTS]
Returns:
A pointer to the brush definition that is currently in the process of being imported.

Definition at line 4322 of file brshcomp.cpp.

04323 {
04324     return m_pImportBrushDef;
04325 }

static UINT32 BrushComponent::GetNumberOfBrushes  )  [inline, static]
 

Definition at line 525 of file brshcomp.h.

00525 {return m_Used;}

String_32 BrushComponent::GetUniqueName String_32 pName = NULL  )  [virtual]
 

When naming a new brush we want to give it the name supplied, however this may well be taken in which case we want to add a number to the default name.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
pName - the name that we wish to use, defaults to NULL in which [INPUTS] case we use the default name
Returns:
A unique name which can be given to the brush

Implements LineComponent.

Definition at line 4555 of file brshcomp.cpp.

04556 {
04557     // essentially what we're doing is going through all the brush definitions and
04558     // retrieving the portion of name that will could be equal to the default name.
04559     // We count the number of default names that we find and once we're finished 
04560     // we use this as the suffix for the new name
04561 
04562     // Get the default name from the resources
04563     String_32 DefaultName(_R(IDS_BRUSH_DEFAULT_NAME));
04564 
04565     if (pName == NULL)
04566         pName = &DefaultName;
04567     
04568     INT32 DefaultSize = pName->Length();
04569 
04570     BrushDefinition* pDef = NULL;
04571     String_32* pDefName = NULL;
04572     String_32 LeftMost;
04573     UINT32 Counter = 0;
04574     INT32 DefaultCounter = 0;
04575 
04576     // loop though the definitions
04577     while (Counter < m_Used)
04578     {
04579         pDef = FindBrushDefinition(Counter);
04580         if (pDef != NULL)
04581         {       
04582             pDefName = pDef->GetLineName();
04583             if (pDefName == NULL)
04584             {
04585                 ERROR3("Brush definition with no name in BrushComponent::GetUniqueName");
04586                 break;
04587             }
04588             // test to see if the leftmost portion of the name is the same as our default
04589             pDefName->Left(&LeftMost, DefaultSize);
04590             if (LeftMost.IsIdentical(*pName))
04591                 DefaultCounter++;
04592 
04593             LeftMost.Empty(); // wipe the default
04594         }
04595         Counter++;
04596     }
04597 
04598     String_32 UniqueName(*pName);
04599     
04600     // do we have to concatenate a number?
04601     if (DefaultCounter > 0)
04602     {
04603         String_32 Concat;
04604         Convert::LongToString(DefaultCounter, &Concat);
04605         UniqueName+=Concat;
04606     }
04607     return UniqueName;
04608 }

BOOL BrushComponent::LoadNextDefaultFile  )  [static]
 

Increments our default file counter.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
- [INPUTS]
Returns:
TRUE if all goes well
See also:
-

Definition at line 3791 of file brshcomp.cpp.

03792 {   
03793     // is this the first file?
03794     if (m_CurrentDefaultFile == BRUSHFILE_NONE)
03795         m_CurrentDefaultFile = 0;
03796     else
03797         m_CurrentDefaultFile++;
03798 
03799     return TRUE;
03800 }

BOOL BrushComponent::NameIsUnique const String_32 NameString  )  [virtual]
 

To find out if someone has already gotten this name.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/7/2000
Parameters:
NameString - the string to test [INPUTS]
Returns:
TRUE if none of the definitions in the component have this string as their name, FALSE if one of them does

Reimplemented from LineComponent.

Definition at line 4628 of file brshcomp.cpp.

04629 {
04630     if (NameString.IsEmpty())
04631         ERROR3("Empty string in BrushComponent::NameIsUnique");
04632     
04633     BOOL Unique = TRUE;
04634     UINT32 Counter = 0;
04635     String_32* pDefName = NULL;
04636     BrushDefinition* pDef = NULL;
04637     while (Counter < m_Used)
04638     {
04639         pDef = FindBrushDefinition(Counter);
04640         if (pDef != NULL)
04641         {
04642             pDefName = pDef->GetLineName();
04643             if( pDefName != NULL )
04644             {
04645                 if (NameString == *pDefName)
04646                 {
04647                     Unique = FALSE;
04648                     break;
04649                 }
04650             }
04651         }
04652         Counter++;
04653     }
04654     return Unique;
04655 
04656 }

void BrushComponent::SetNewName String_32  NewName  )  [static]
 

Definition at line 4658 of file brshcomp.cpp.

04659 {
04660     m_NewName = NewName;
04661 }

BOOL BrushComponent::StartExport BaseCamelotFilter pFilter  )  [virtual]
 

Called before an export is started.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
pFilter - the BaseCamelotFilter filter that is being used to export a file. [INPUTS]
Returns:
TRUE if the component was able to prepare for exporting; FALSE if not (e.g. out of memory)

Implements LineComponent.

Definition at line 3947 of file brshcomp.cpp.

03948 {
03949 //  return TRUE; // for now
03950 #if !defined(EXCLUDE_FROM_RALPH)
03951     
03952     if (pFilter == NULL)
03953     {
03954         ERROR3("BrushComponent::StartExport filter is null!");
03955         return(TRUE);
03956     }
03957 
03958     // ****!!!!TODO - if we're multi-threadig, this probably needs to be a critical section
03959     // because the list is global
03960 
03961     // Flag all Brushs as not having been saved. When we save one, we set its flag so that
03962     // we don't try to save it a second time.
03963     if (m_pLineArray != NULL)
03964     {
03965         for (UINT32 Index = 0; Index < m_Used; Index++)
03966         {
03967             if (m_pLineArray[Index] != NULL)
03968                     m_pLineArray[Index]->SetIOStore(FALSE);
03969         }
03970 
03971         // Write out an atomic tag definition in front of the vector Brush definition.
03972         // ****!!!!TODO - This should really only be done just before we export the first
03973         // BrushDEFINITION tag, but it is not properly supported by the export system as yet.
03974         
03975         //TODO : Make tags for brush components!!
03976         
03977         BOOL ok = TRUE;
03978         CXaraFileRecord Rec(TAG_ATOMICTAGS, TAG_ATOMICTAGS_SIZE);
03979         if (ok) ok = Rec.Init();
03980         if (ok) ok = Rec.WriteUINT32(TAG_BRUSHDEFINITION);
03981         if (ok) pFilter->Write(&Rec);       // And write out the record
03982         
03983     }
03984 #endif
03985     return(TRUE);
03986 }

BOOL BrushComponent::StartImportBrush CamelotRecordHandler pHandler,
CXaraFileRecord pRecord,
UINT32  ImportHandle
 

To import a vector Line definition.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/12/99
Parameters:
pRecord - The TAG_BRUSHDEFINITION record to import [INPUTS]
Returns:
TRUE if Import was successful

Definition at line 4004 of file brshcomp.cpp.

04006 {
04007     m_ImportHandle = 0xffffffff;
04008     
04009     if (m_pImportPreviousContext != NULL)
04010     {
04011     //  delete m_pImportPreviousContext;
04012         m_pImportPreviousContext = NULL;
04013     }
04014 
04015     if (m_pImportNewLine != NULL)
04016     {
04017         m_pImportNewLine->CascadeDelete();
04018         m_pImportNewLine = NULL;
04019     }
04020 
04021     // Create a spread and set up the import system to import the brush into it
04022     // If this fails, then it'll just find somewhere "sensible" to import into
04023     m_pImportNewLine = new Spread;
04024     if (m_pImportNewLine == NULL)
04025         return(FALSE);
04026 
04027     Layer *pLineLayer = new Layer(m_pImportNewLine, FIRSTCHILD, String_256(TEXT("Jason did this")));
04028     if (pLineLayer == NULL)
04029     {
04030         delete m_pImportNewLine;
04031         m_pImportNewLine = NULL;
04032         return(FALSE);
04033     }
04034 
04035     // Now, remember where we were importing into, and point the importer at our brush tree
04036     m_pImportPreviousContext = pHandler->GetInsertContext();
04037     pHandler->SetInsertContextNode(pLineLayer);
04038 
04039     // check to see if our import brushdef already exists, if so delete it
04040     if (m_pImportBrushDef != NULL)
04041         delete m_pImportBrushDef;
04042     // make the new brush definition
04043     m_pImportBrushDef = new BrushDefinition(m_pImportNewLine);
04044     if (m_pImportBrushDef == NULL)
04045         return(FALSE);
04046 
04047 
04048 
04049     // Remember the handle used for the Brush in the file with the Brush so that
04050     // we can map any incoming handles into the real handles we are using internally.
04051     m_pImportBrushDef->SetIOStore(ImportHandle & 0x00ffffff);
04052 
04053 
04054     /* in case you were wondering, after this function the import goes as follows:
04055     - Ink nodes etc. are imported into m_pImportNewLine
04056     - Brush data is imported
04057     - EndImportBrush is called, where the new brush definition is inserted
04058     */
04059     
04060 
04061 
04062     return(TRUE);
04063 }


Member Data Documentation

BOOL BrushComponent::m_bCancelNewBrush = FALSE [static, private]
 

Definition at line 575 of file brshcomp.h.

UINT32 BrushComponent::m_CurrentDefaultFile = BRUSHFILE_NONE [static, private]
 

Definition at line 576 of file brshcomp.h.

String_32 BrushComponent::m_NewName = TEXT("Unnamed brush") [static, private]
 

Definition at line 574 of file brshcomp.h.

BrushDefinition* BrushComponent::m_pImportBrushDef [private]
 

Definition at line 565 of file brshcomp.h.

MILLIPOINT BrushComponent::m_StoreOffsetValue [private]
 

Definition at line 572 of file brshcomp.h.

PathOffset BrushComponent::m_StorePathOffsetType [private]
 

Definition at line 571 of file brshcomp.h.

BOOL BrushComponent::m_StoreRotate [private]
 

Definition at line 569 of file brshcomp.h.

double BrushComponent::m_StoreRotateAngle [private]
 

Definition at line 570 of file brshcomp.h.

MILLIPOINT BrushComponent::m_StoreSpacing [private]
 

Definition at line 567 of file brshcomp.h.

BOOL BrushComponent::m_StoreTile [private]
 

Definition at line 568 of file brshcomp.h.


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