00001 // $Id: webattr.h 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 // Definition of the new Web Address attribute 00100 00101 #ifndef INC_WEBATTR 00102 #define INC_WEBATTR 00103 00104 //#include "nodeattr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 //#include "attr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 //#include "attrval.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 //#include "hotlink.h" 00109 #include "webaddr.h" //Class WebAddress 00110 00111 class BlendAttrParam; 00112 class BaseCamelotFilter; 00113 class TextChar; 00114 class CamelotFileRecord; 00115 00116 /******************************************************************************************** 00117 00118 > class WebAddressAttribute : public AttributeValue 00119 00120 Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> 00121 00122 Created: 18/3/97 00123 00124 Purpose: The new Web Address attribute. It's distinct from the old Web 00125 Address attribute, which was a type of UserAttribute. 00126 00127 It stores three member variables: 00128 00129 m_url A WebAddress object: 00130 The URL to fetch when the object to which the 00131 attribute is applied is clicked on 00132 00133 m_fBounding Whether the clickable area of the object to which 00134 the attribute is applied is the bounding box or 00135 the actual shape of the object 00136 00137 m_pcFrame (Optional) 00138 The name of a frame into which to fetch the URL 00139 00140 It also stores the following rectangle: 00141 00142 m_rectClickableInRendering 00143 00144 This member variable is an oddity and it works as follows. 00145 00146 When this WebAddressAttribute is contained in an AttrWebAddress in 00147 the Camelot tree, then the clickable rectangle of the Web 00148 Address Attribute is easily obtained from the parent of the 00149 AttrWebAddress in the tree. 00150 00151 But when this WebAddressAttribute is set into a RenderRegion, 00152 there is no way of finding out the clickable rectangle of the 00153 Web Address attribute. But at the same time the WebAddressAttribute 00154 *must* know its clickable rectangle. 00155 00156 So, this is what happens. When the AttrWebAddress is called to 00157 render the WebAddressAttribute, it does the following: 00158 00159 a. Makes a copy of the WebAddressAttribute 00160 b. Finds out the clickable rectangle 00161 c. Stores the clickable rectangle in the WebAddressAttribute 00162 d. Sets the WebAddressAttribute into the RenderRegion. 00163 00164 The moral of the story is: to find the clickable rectangle when the 00165 attribute is stored in the tree, use AttrWebAddress::GetClickableRectangle. 00166 Don't call AttrWebAddress::GetClickableRectangleInRendering. 00167 00168 ********************************************************************************************/ 00169 00170 class WebAddressAttribute : public AttributeValue 00171 { 00172 CC_DECLARE_DYNCREATE(WebAddressAttribute) 00173 00174 //Constructors and initialiser 00175 public: 00176 WebAddressAttribute(); 00177 00178 WebAddressAttribute(WebAddress url, 00179 BOOL fBounding=FALSE, 00180 TCHAR* pcFrame=NULL); 00181 00182 WebAddressAttribute(TCHAR* pcURL, 00183 BOOL fBounding=FALSE, 00184 TCHAR* pcFrame=NULL); 00185 00186 00187 00188 00189 00190 static BOOL Init(); 00191 00192 //Destructor, copy constructor and assignment operator 00193 public: 00194 ~WebAddressAttribute(); 00195 WebAddressAttribute(const WebAddressAttribute& waaCopy); 00196 WebAddressAttribute& operator=(const WebAddressAttribute& waaCopy); 00197 00198 00199 //Operations 00200 public: 00201 virtual void Render(RenderRegion* pRegion, BOOL Temp = FALSE); 00202 virtual void Restore(RenderRegion* pRegion, BOOL Temp); 00203 00204 virtual void SimpleCopy(AttributeValue *); 00205 virtual NodeAttribute *MakeNode(); 00206 BOOL IsDifferent(AttributeValue *pAttr); 00207 00208 virtual BOOL Blend(BlendAttrParam* pBlendParam); 00209 00210 //Access functions 00211 public: 00212 void SetClickableRectangleInRendering(DocRect rectNew) 00213 { 00214 m_rectClickableInRendering=rectNew; 00215 } 00216 00217 DocRect GetClickableRectangleInRendering() 00218 { 00219 return m_rectClickableInRendering; 00220 } 00221 00222 BOOL HasURL() 00223 { 00224 return (!m_url.IsEmpty()); 00225 } 00226 00227 BOOL UseBoundingRectangle() 00228 { 00229 return m_fBounding; 00230 } 00231 00232 //Toolkit functions 00233 public: 00234 static void CopyString(TCHAR** ppcCopyTo, const TCHAR* pcCopyFrom); 00235 static BOOL AreStringsEqual(TCHAR* pcFirst, TCHAR* pcSecond); 00236 00237 //Member variables. See comments above for a description 00238 public: 00239 WebAddress m_url; 00240 BOOL m_fBounding; 00241 TCHAR* m_pcFrame; 00242 00243 DocRect m_rectClickableInRendering; 00244 }; 00245 00246 00247 /*********************************************************************************************** 00248 00249 > class AttrWebAddress : public NodeAttribute 00250 00251 Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> 00252 Created: 18/3/97 00253 Purpose: The new Web Address attribute. This is distinct from the old 00254 Web Address attribute from CorelXARA 1.5, which was a type of 00255 AttrUser. 00256 00257 ***********************************************************************************************/ 00258 00259 class AttrWebAddress : public NodeAttribute 00260 { 00261 CC_DECLARE_DYNCREATE(AttrWebAddress) 00262 00263 //Constructors 00264 public: 00265 AttrWebAddress(); 00266 AttrWebAddress(Node* ContextNode, 00267 AttachNodeDirection Direction, 00268 BOOL Locked=FALSE, 00269 BOOL Mangled=FALSE, 00270 BOOL Marked=FALSE, 00271 BOOL Selected=FALSE); 00272 AttrWebAddress(WebAddress url, BOOL fBounding=FALSE, TCHAR* pcFrame=NULL); 00273 AttrWebAddress(TCHAR* pcURL, BOOL fBounding=FALSE, TCHAR* pcFrame=NULL); 00274 virtual AttrIndex GetAttributeIndex () { return ATTR_WEBADDRESS; } 00275 00276 //Overloaded operators 00277 public: 00278 virtual INT32 operator==(const NodeAttribute& NodeAttrib); 00279 00280 00281 //Operations 00282 public: 00283 void Render( RenderRegion* pRender ); 00284 virtual BOOL Blend(BlendAttrParam* pBlendParam); 00285 00286 virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter); 00287 virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter); 00288 00289 Node* SimpleCopy(); 00290 00291 //Information functions 00292 public: 00293 virtual UINT32 GetAttrNameID(void) 00294 { 00295 return (_R(IDS_WEBADDRESSATTRIBUTE_ID)); 00296 } 00297 00298 virtual UINT32 GetNodeSize() const 00299 { 00300 return sizeof(AttrWebAddress); 00301 } 00302 00303 virtual AttributeValue* GetAttributeValue() 00304 { 00305 return &Value; 00306 } 00307 00308 virtual CCRuntimeClass* GetAttributeType() 00309 { 00310 return CC_RUNTIME_CLASS(AttrWebAddress); 00311 } 00312 00313 BOOL ShouldBecomeCurrent() 00314 { 00315 return FALSE; 00316 } 00317 00318 00319 DocRect GetClickableRectangle(); 00320 00321 virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy); 00322 00323 //Debug functions 00324 public: 00325 void GetDebugDetails(StringBase* Str); 00326 void ShowDebugTreeDetails() const; 00327 00328 //Toolkit functions 00329 private: 00330 BOOL WriteString(CamelotFileRecord* pcfrRecord, TCHAR* pcWrite); 00331 void CopyNodeContents( AttrWebAddress* NodeCopy ); 00332 00333 //Member variables 00334 public: 00335 WebAddressAttribute Value; 00336 }; 00337 00338 00339 /******************************************************************************************** 00340 00341 > virtual UINT32 AttrWebAddress::GetAttrNameID(void) 00342 00343 Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Simon 00344 Created: 22/2/94 00345 Inputs: - 00346 Outputs: - 00347 Returns: Attribute description ID 00348 Purpose: Returns back a string resource ID describing the attribute 00349 00350 Errors: - 00351 SeeAlso: - 00352 00353 ********************************************************************************************/ 00354 /******************************************************************************************** 00355 00356 > virtual UINT32 AttrWebAddress::GetNodeSize() const 00357 00358 Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Simon 00359 Created: 6/10/93 00360 Inputs: - 00361 Outputs: - 00362 Returns: The size of the node in bytes 00363 Purpose: For finding the size of the node 00364 00365 SeeAlso: Node::GetSubtreeSize 00366 00367 ********************************************************************************************/ 00368 /******************************************************************************************** 00369 00370 > BOOL AttrUser::ShouldBecomeCurrent() 00371 00372 Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> 00373 Created: 23/3/97 00374 Returns: TRUE if this attribute should become current. 00375 00376 FALSE if the user must deliberately apply this attribute to an object 00377 every time he wants to use it. 00378 00379 Purpose: The attribute manager calls this function before making an attribute current. 00380 00381 There are some attributes - like this WebAddress attribute I'm about 00382 to put in - that the user probably won't want to become current. 00383 For example, if a user puts a HotLink on an object and happens to have 00384 the Give Other Objects Most Recent Attributes option on, all his new objects are 00385 going to have HotLinks. That's not good. 00386 00387 So those attributes will override this function and return FALSE. 00388 00389 ********************************************************************************************/ 00390 00391 /******************************************************************************************** 00392 00393 > BOOL WebAddressAttribute::HasURL() 00394 00395 Author: Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> 00396 Created: 16/4/97 00397 Returns: TRUE if this WebAddressAttribute has a non-empty URL 00398 FALSE if this WebAddressAttribute has an empty URL 00399 00400 Purpose: The definitive test to find whether this attribute 00401 contains a link to a Web Address. Used to decide 00402 whether to let this WebAddressAttribute specify 00403 a region in an imagemap. 00404 00405 The test to find whether the URL is empty is: 00406 a. EITHER m_pcURL is NULL 00407 b. OR m_pcURL points to a NULL character 00408 00409 ********************************************************************************************/ 00410 00411 00412 #endif //ifdef INC_WEBATTR