WebAddressAttribute Class Reference

The new Web Address attribute. It's distinct from the old Web Address attribute, which was a type of UserAttribute. More...

#include <webattr.h>

Inheritance diagram for WebAddressAttribute:

AttributeValue CCObject SimpleCCObject List of all members.

Public Member Functions

 WebAddressAttribute ()
 Default constructor.
 WebAddressAttribute (WebAddress url, BOOL fBounding=FALSE, TCHAR *pcFrame=NULL)
 Specific constructor for a Web Address attribute.
 WebAddressAttribute (TCHAR *pcURL, BOOL fBounding=FALSE, TCHAR *pcFrame=NULL)
 Specific constructor for a Web Address attribute.
 ~WebAddressAttribute ()
 Destructor.
 WebAddressAttribute (const WebAddressAttribute &waaCopy)
 Copy constructor.
WebAddressAttributeoperator= (const WebAddressAttribute &waaCopy)
 Assignment operator.
virtual void Render (RenderRegion *pRegion, BOOL Temp=FALSE)
 Sets this Web Address attribute as current within the render region.
virtual void Restore (RenderRegion *pRegion, BOOL Temp)
 Restores this Web Address attribute into the region.
virtual void SimpleCopy (AttributeValue *)
 Assignment operator.
virtual NodeAttributeMakeNode ()
 Make a AttrWebAddress node from this line width attribute.
BOOL IsDifferent (AttributeValue *pAttr)
 Determines whether the two attributes are different.
virtual BOOL Blend (BlendAttrParam *pBlendParam)
 Blends this attr val with the attr val held in pBlendParam.
void SetClickableRectangleInRendering (DocRect rectNew)
DocRect GetClickableRectangleInRendering ()
BOOL HasURL ()
BOOL UseBoundingRectangle ()

Static Public Member Functions

static BOOL Init ()
 Registers the default WebAddressAttribute.
static void CopyString (TCHAR **ppcCopyTo, const TCHAR *pcCopyFrom)
 IF pcCopyFrom is NULL then the string pointer that ppcCopyTo is set to NULL.
static BOOL AreStringsEqual (TCHAR *pcFirst, TCHAR *pcSecond)
 To compare two string pointers b Note that this function handles its input parameters being NULL.

Public Attributes

WebAddress m_url
BOOL m_fBounding
TCHARm_pcFrame
DocRect m_rectClickableInRendering

Detailed Description

The new Web Address attribute. It's distinct from the old Web Address attribute, which was a type of UserAttribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/3/97
It stores three member variables:

m_url A WebAddress object: The URL to fetch when the object to which the attribute is applied is clicked on

m_fBounding Whether the clickable area of the object to which the attribute is applied is the bounding box or the actual shape of the object

m_pcFrame (Optional) The name of a frame into which to fetch the URL

It also stores the following rectangle:

m_rectClickableInRendering

This member variable is an oddity and it works as follows.

When this WebAddressAttribute is contained in an AttrWebAddress in the Camelot tree, then the clickable rectangle of the Web Address Attribute is easily obtained from the parent of the AttrWebAddress in the tree.

But when this WebAddressAttribute is set into a RenderRegion, there is no way of finding out the clickable rectangle of the Web Address attribute. But at the same time the WebAddressAttribute must* know its clickable rectangle.

So, this is what happens. When the AttrWebAddress is called to render the WebAddressAttribute, it does the following:

a. Makes a copy of the WebAddressAttribute b. Finds out the clickable rectangle c. Stores the clickable rectangle in the WebAddressAttribute d. Sets the WebAddressAttribute into the RenderRegion.

The moral of the story is: to find the clickable rectangle when the attribute is stored in the tree, use AttrWebAddress::GetClickableRectangle. Don't call AttrWebAddress::GetClickableRectangleInRendering.

Definition at line 170 of file webattr.h.


Constructor & Destructor Documentation

WebAddressAttribute::WebAddressAttribute  ) 
 

Default constructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 718 of file webattr.cpp.

00719 {
00720     //Set the URL to a default
00721     m_url=WebAddress();
00722 
00723     //Put "_self" into the Frame member variable
00724     String_256 strSelf(_R(IDS_WEBADDRESS_SHORT_SELF));
00725 
00726     m_pcFrame=NULL;
00727 
00728     CopyString(&m_pcFrame, strSelf);
00729 
00730     //Set the bounding flag to FALSE
00731     m_fBounding=FALSE;
00732 }

WebAddressAttribute::WebAddressAttribute WebAddress  url,
BOOL  fBounding = FALSE,
TCHAR pcFrame = NULL
 

Specific constructor for a Web Address attribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
New values for member variables [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 749 of file webattr.cpp.

00750 {
00751     //First set our member variable string pointer to NULL, 
00752     //so that CopyString doesn't try to delete it
00753     m_pcFrame=NULL;
00754     
00755     //Then copy everything into our member variables
00756     m_url=url;
00757     CopyString(&m_pcFrame, pcFrame);
00758     m_fBounding=fBounding;
00759 
00760     //And set the clickable in rendering rectangle to a zero value
00761     //(See header file for a description of this variable)
00762     m_rectClickableInRendering=DocRect(0,0,0,0);
00763 }

WebAddressAttribute::WebAddressAttribute TCHAR pcURL,
BOOL  fBounding = FALSE,
TCHAR pcFrame = NULL
 

Specific constructor for a Web Address attribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
New values for member variables [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 780 of file webattr.cpp.

00781 {
00782     //Simply put pcURL into a string
00783     String_256 strURL=pcURL;
00784 
00785     //Put that into a Web Address
00786     WebAddress urlURL(strURL);
00787 
00788     m_pcFrame=NULL;
00789 
00790     //And make our attribute as normal
00791     *this=WebAddressAttribute(urlURL, fBounding, pcFrame);
00792 }

WebAddressAttribute::~WebAddressAttribute  ) 
 

Destructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 874 of file webattr.cpp.

00875 {
00876     if (m_pcFrame)
00877         free(m_pcFrame);
00878 }

WebAddressAttribute::WebAddressAttribute const WebAddressAttribute waaCopy  ) 
 

Copy constructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
WebAddressAttribute to copy [INPUTS]
- [OUTPUTS]
Returns:
*this

Errors: -

See also:
-

Definition at line 847 of file webattr.cpp.

00848 {
00849     //Set our member variables to NULL
00850     m_pcFrame=NULL;
00851 
00852     m_rectClickableInRendering=DocRect(0,0,0,0);
00853 
00854     //Simply use the assigment operator
00855     *this=waaCopy;
00856                            
00857 }


Member Function Documentation

BOOL WebAddressAttribute::AreStringsEqual TCHAR pcFirst,
TCHAR pcSecond
[static]
 

To compare two string pointers b Note that this function handles its input parameters being NULL.

BOOL WebAddressAttribute::AreStringsEqual(TCHAR* pcFirst, TCHAR* pcSecond)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
pcFirst,pcSecond - the two strings to compare [INPUTS]
ppcCopyTo [OUTPUTS]
Returns:
TRUE IF pcFirst, pcSecond are both NULL OR if they point to identical strings FALSE otherwise
See also:
-

Definition at line 1172 of file webattr.cpp.

01173 {
01174     //If either of our incoming string pointers is NULL
01175     if (pcFirst==NULL || pcSecond==NULL)
01176         //Then return TRUE if they are both NULL and FALSE otherwise
01177         return (pcFirst==pcSecond);
01178 
01179     //Otherwise, return the result of comparing the two strings
01180     return (camStrcmp(pcFirst, pcSecond)==0);
01181 }

BOOL WebAddressAttribute::Blend BlendAttrParam pBlendParam  )  [virtual]
 

Blends this attr val with the attr val held in pBlendParam.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Markn
Date:
27/3/97
Parameters:
pBlendParam = ptr to param holding all data needed for the attr val to blend [INPUTS]
if TRUE returned, pBlendParam->GetBlendedAttrVal() will get ptr to the blended attr val [OUTPUTS] if FALSE returned, pBlendParam->GetBlendedAttrVal() will return NULL
Returns:
TRUE if successful, FALSE otherwaie
See also:
-

Reimplemented from AttributeValue.

Definition at line 1058 of file webattr.cpp.

01059 {
01060     // Check entry param
01061     ERROR3IF(pBlendParam == NULL,"NULL entry param");
01062     if (pBlendParam == NULL) return FALSE;
01063 
01064     WebAddressAttribute* pOtherWebAttr = (WebAddressAttribute*) pBlendParam->GetOtherAttrVal();
01065     
01066     // Check that the other line attr val is not NULL, and is a WebAddressAttribute
01067     ERROR3IF(pOtherWebAttr == NULL,"NULL other attr val");
01068     ERROR3IF(!IS_A(pOtherWebAttr,WebAddressAttribute),"other attr val not a Web Address attr");
01069     if (pOtherWebAttr == NULL || !IS_A(pOtherWebAttr,WebAddressAttribute)) return FALSE;
01070 
01071     // If both attributes do not have a URL then we must return FALSE. 
01072     // Bug fix - Ranbirr 17/03/98
01073     if(!this->HasURL() && !pOtherWebAttr->HasURL())
01074         return FALSE;
01075 
01076     // Get a new WebAddressAttribute to hold the blended version, (return FALSE if this fails)
01077     WebAddressAttribute* pBlendedWebAttr = new WebAddressAttribute;
01078     if (pBlendedWebAttr == NULL) return FALSE;
01079 
01080     //If the blend ratio is less than 0.5, we use this WebAddressAttribute.
01081     //Otherwise, we use the other WebAddressAttribute
01082     double dRatio=pBlendParam->GetBlendRatio();
01083 
01084     if (dRatio<0.5)
01085         *pBlendedWebAttr=*this;
01086     else
01087         *pBlendedWebAttr=*pOtherWebAttr;
01088 
01089     // Store the ptr to the new blended line width attr val
01090     pBlendParam->SetBlendedAttrVal(pBlendedWebAttr);
01091 
01092     return TRUE;
01093 }

void WebAddressAttribute::CopyString TCHAR **  ppcCopyTo,
const TCHAR pcCopyFrom
[static]
 

IF pcCopyFrom is NULL then the string pointer that ppcCopyTo is set to NULL.

void WebAddressAttribute::CopyString(TCHAR** ppcCopyTo, const TCHAR* pcCopyFrom)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
ppcCopyTo Pointer to a string pointer to copy the string to [INPUTS] pcCopyFrom String pointer to copy from
ppcCopyTo [OUTPUTS]
Returns:
-
ELSE IF pcCopyFrom points to a string then that string is copied into the string pointer that pcCopyTo pointer to

This function will handle pcCopyFrom or *ppcCopyTo being NULL, but ppcCopyTo must be valid. It's obvious if you think about it.

See also:
-

Definition at line 1126 of file webattr.cpp.

01127 {
01128     //We need to check that ppcCopyTo is valid
01129     if (ppcCopyTo==NULL)
01130     {
01131         ERROR2RAW("WebAddress::CopyString passed NULL parameter");
01132         return;
01133     }
01134 
01135     //Now, if *ppcCopyTo points to a string, we delete it now
01136     if (*ppcCopyTo)
01137     {
01138         free (*ppcCopyTo);
01139         *ppcCopyTo=NULL;    
01140     }
01141         
01142     //Does pcCopyFrom point to a string?
01143     if (pcCopyFrom)
01144     {
01145         //Yes (we assume it does if it's not NULL)
01146         //So copy that string into *ppcCopyTo
01147         (*ppcCopyTo) = camStrdup( pcCopyFrom );
01148     }
01149 
01150     //If pcCopyFrom is NULL, then ppcCopyTo is NULL, which is correct
01151     //So return
01152 }

DocRect WebAddressAttribute::GetClickableRectangleInRendering  )  [inline]
 

Definition at line 217 of file webattr.h.

00218     {
00219         return m_rectClickableInRendering;
00220     }

BOOL WebAddressAttribute::HasURL  )  [inline]
 

Definition at line 222 of file webattr.h.

00223     {
00224         return (!m_url.IsEmpty());
00225     }

BOOL WebAddressAttribute::Init void   )  [static]
 

Registers the default WebAddressAttribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 810 of file webattr.cpp.

00811 {
00812     WebAddressAttribute *pAttr = new WebAddressAttribute();
00813     
00814     if (pAttr == NULL)
00815         return FALSE;
00816 
00817     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
00818                                                          pAttr);
00819     if (ID == ATTR_BAD_ID)
00820         return FALSE;
00821 
00822     ENSURE(ID == ATTR_WEBADDRESS, "Incorrect ID for Web Address attribute!");
00823     return TRUE;
00824 }

BOOL WebAddressAttribute::IsDifferent AttributeValue pAttr  )  [virtual]
 

Determines whether the two attributes are different.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
If the two attributes are of different types, FALSE is returned.

Returns:
Errors: -
See also:
AttributeValue::IsDifferent

Reimplemented from AttributeValue.

Definition at line 1022 of file webattr.cpp.

01023 {
01024     //Check parameter
01025     ERROR2IF(pAttr==NULL, FALSE, "WebAddressAttribute::IsDifferent - NULL parameter");
01026 
01027     //If pAttr doesn't point to a WebAddressAttribute, return FALSE
01028     if (!pAttr->IsKindOf(CC_RUNTIME_CLASS(WebAddressAttribute)))
01029         return FALSE;
01030 
01031     //Cast pAttr into a WebAddressAttribute*
01032     WebAddressAttribute* pwaaThis=(WebAddressAttribute*) pAttr;
01033 
01034     //And now check whether each of the member strings are different
01035     BOOL fSameURL=(m_url==pwaaThis->m_url);
01036     BOOL fSameFrame=AreStringsEqual(m_pcFrame, pwaaThis->m_pcFrame);
01037     BOOL fSameArea=(m_fBounding==pwaaThis->m_fBounding);
01038         
01039     //If any of them were different, return TRUE
01040     return (!fSameURL || !fSameFrame || !fSameArea);
01041 }

NodeAttribute * WebAddressAttribute::MakeNode  )  [virtual]
 

Make a AttrWebAddress node from this line width attribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Tim
Date:
27/3/97
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 995 of file webattr.cpp.

00996 {
00997     // Create new attribute node
00998     AttrWebAddress *pAttr = new AttrWebAddress();
00999 
01000     // Copy attribute value into the new node
01001     pAttr->Value=*this;
01002 
01003     // Return the new node
01004     return pAttr;
01005 }

WebAddressAttribute & WebAddressAttribute::operator= const WebAddressAttribute waaOther  ) 
 

Assignment operator.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
waaOther Attribute to copy [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 895 of file webattr.cpp.

00896 {
00897     //Copy everything into our member variables
00898     m_url=waaOther.m_url;
00899     CopyString(&m_pcFrame, waaOther.m_pcFrame);
00900     m_rectClickableInRendering=waaOther.m_rectClickableInRendering;
00901     m_fBounding=waaOther.m_fBounding;
00902 
00903     return *this;
00904 }

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

Sets this Web Address attribute as current within the render region.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/3/97
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]
Note that nothing is actually seen on screen as a result of rendering the Web Address Attribute.

Implements AttributeValue.

Definition at line 927 of file webattr.cpp.

00928 {
00929     pRegion->SetWebAddress(this, Temp);
00930 }

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

Restores this Web Address attribute into the region.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/3/97
Parameters:
pRegion - the render region to render this attribute into. [INPUTS]

Implements AttributeValue.

Definition at line 943 of file webattr.cpp.

00944 {
00945     pRegion->RestoreWebAddress(this, Temp);
00946 }

void WebAddressAttribute::SetClickableRectangleInRendering DocRect  rectNew  )  [inline]
 

Definition at line 212 of file webattr.h.

00213     {
00214         m_rectClickableInRendering=rectNew;
00215     }

void WebAddressAttribute::SimpleCopy AttributeValue pValue  )  [virtual]
 

Assignment operator.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/3/97
Parameters:
pValue - pointer to the value to copy [INPUTS]
See also:
WebAddressAttribute::operator=

Implements AttributeValue.

Definition at line 960 of file webattr.cpp.

00961 {
00962     //Check parameter
00963     if (pValue==NULL)
00964     {
00965         ERROR2RAW("WebAddressAttribute::SimpleCopy - NULL parameter");
00966         return;
00967     }
00968 
00969 
00970 
00971     //If pValue is a Web Address
00972     if (pValue->IsKindOf(CC_RUNTIME_CLASS(WebAddressAttribute)))
00973     {
00974         //Copy it into this attribute
00975         *this=*((WebAddressAttribute*) pValue);
00976     }
00977     else
00978         //Make this attribute blank
00979         *this=WebAddressAttribute();
00980 }

BOOL WebAddressAttribute::UseBoundingRectangle  )  [inline]
 

Definition at line 227 of file webattr.h.

00228     {
00229         return m_fBounding;
00230     }


Member Data Documentation

BOOL WebAddressAttribute::m_fBounding
 

Definition at line 240 of file webattr.h.

TCHAR* WebAddressAttribute::m_pcFrame
 

Definition at line 241 of file webattr.h.

DocRect WebAddressAttribute::m_rectClickableInRendering
 

Definition at line 243 of file webattr.h.

WebAddress WebAddressAttribute::m_url
 

Definition at line 239 of file webattr.h.


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