attrval.h

Go to the documentation of this file.
00001 // $Id: attrval.h 1445 2006-07-14 20:15:02Z phil $
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 // Defines AttributeValue and some derived classes 
00100 
00101 #ifndef INC_ATTRVAL
00102 #define INC_ATTRVAL
00103 
00104 #include "doccoord.h"
00105 #include "doccolor.h"
00106 #include "ensure.h"
00107 #include "attr.h"
00108 #include "arrows.h"
00109 #include "node.h"
00110 
00111 class Path;
00112 class RenderRegion;
00113 class Node;
00114 class NodeAttribute;
00115 class BlendAttrParam;
00116 class PathStrokerVector;
00117 
00118 /********************************************************************************************
00119 
00120 >   class AttributeValue : public CCObject
00121 
00122     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00123     Created:    26/01/94
00124     Purpose:    To encapsulate rendering attributes.  Derivations of NodeAttribute will
00125                 hold an instance of this class (or derivation of it) to store the
00126                 attribute information - this instance field should always be called 'Value'.
00127                 An AttributeValue object is capable of being pushed onto and popped off the
00128                 render context stack, and being rendered.  This is accomplished by using
00129                 virtual functions to perform these operations.
00130     SeeAlso:    NodeAttribute; RenderStack
00131 
00132 ********************************************************************************************/
00133 
00134 class AttributeValue : public CCObject
00135 {
00136     CC_DECLARE_DYNCREATE(AttributeValue)
00137 public:
00138     AttributeValue() {};
00139     virtual ~AttributeValue() {};
00140 
00141     virtual void Render(RenderRegion *, BOOL Temp = FALSE) = 0;
00142             // Called to "render" an attribute (makes it current for the first time)
00143 
00144     virtual void Restore(RenderRegion *, BOOL Temp) = 0;
00145             // Called to "restore" a stacked attribute (makes it current once more)
00146 
00147     virtual void GoingOutOfScope(RenderRegion *pRender) {};
00148             // Called when a current attribute goes out of scope
00149             // (only called once, when the attribute is "popped" from being current)
00150             // Used to allow us to remove any PathProcessor we may have added to the RndRgn
00151 
00152     virtual void SimpleCopy(AttributeValue *) = 0;
00153     virtual NodeAttribute *MakeNode();
00154     virtual NodeAttribute *MakeNode(Node* pContextNode, AttachNodeDirection Direction);
00155     virtual BOOL IsDifferent(AttributeValue*);
00156 
00157     // This blends the attribute value with the one provided by pBlendParam
00158     virtual BOOL Blend(BlendAttrParam* pBlendParam);
00159 
00160     virtual INT32 operator=(AttributeValue& Attrib) { return TRUE; }
00161 
00162 public:
00163     virtual AttributeValue *MouldIntoStroke(PathStrokerVector *pMoulder, double TransScale = 1.0);
00164             // Moulds the attribute into the given Stroke envelope. This translates fill
00165             // handles, and scales transparency values and line widths (etc). The base class
00166             // does nothing.
00167 
00168     // There is only one case to date where AttributeValue are rendered directly ie without calling the render function of their
00169     // associated/containing NodeAttribute class. This occurs in RenderRegion::InitDevice().
00170     // This function is to determine if the AttributeValue can be rendered independently of the NodeAttribute.
00171     // It is only used in RR::InitDevice() at present but I am defining it in order to highlight this new characteristic of
00172     // nodes which are geometry dependent, in order to ensure that this becomes an acknowledged attribute design consideration
00173     // (ie so that these special cases get handled correctly by future code which may need to render attributes directly)
00174     virtual BOOL CanBeRenderedDirectly();
00175 };
00176 
00177 /********************************************************************************************
00178 
00179 >   class LineWidthAttribute : public AttributeValue
00180 
00181     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00182     Created:    15/06/94
00183     Purpose:    Represent a line width of a path.  This may be a simple stroking operator
00184                 such as a constant line width, or a complex one such as variable line
00185                 widths or an airbrush stroke operator.
00186     SeeAlso:    FillColourAttribute; StrokeColourAttribute;
00187                 StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00188                 JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute;
00189                 DashPatternAttribute
00190 
00191 ********************************************************************************************/
00192 
00193 class LineWidthAttribute : public AttributeValue
00194 {
00195     CC_DECLARE_DYNCREATE(LineWidthAttribute)
00196 public:
00197     LineWidthAttribute();
00198     LineWidthAttribute(MILLIPOINT NewLineWidth) { LineWidth = NewLineWidth; }
00199     virtual void Restore(RenderRegion *, BOOL);
00200     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00201     virtual NodeAttribute *MakeNode();
00202     BOOL IsDifferent(AttributeValue *pAttr);
00203     virtual void SimpleCopy(AttributeValue *);
00204 
00205     // This blend the attribute value with the one provided by pBlendParam
00206     virtual BOOL Blend(BlendAttrParam* pBlendParam);
00207 
00208     // Extra virtual function for stroke type attributes.
00209     virtual BOOL RenderStroke(RenderRegion *, Path *) { return FALSE; }
00210 
00211     // Simplified colour for render regions that can only handle simple line widths.
00212     MILLIPOINT LineWidth;
00213 
00214     static BOOL Init();
00215 
00216 public:
00217     virtual AttributeValue *MouldIntoStroke(PathStrokerVector *pMoulder, double TransScale = 1.0);
00218             // Moulds the attribute into the given Stroke envelope. This translates fill
00219             // handles, and scales transparency values and line widths (etc). The base class
00220             // does nothing.
00221 };
00222 
00223 /********************************************************************************************
00224 
00225 >   class StartArrowAttribute : public AttributeValue
00226 
00227     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00228     Created:    26/01/94
00229     Purpose:    Attribute for start arrow type of paths.
00230     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00231                 EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00232                 JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute;
00233                 DashPatternAttribute
00234 
00235 ********************************************************************************************/
00236 
00237 class StartArrowAttribute : public AttributeValue
00238 {
00239     CC_DECLARE_DYNCREATE(StartArrowAttribute)
00240 public:
00241     virtual void Restore(RenderRegion *, BOOL);
00242     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00243     virtual void SimpleCopy(AttributeValue *);
00244     virtual NodeAttribute *MakeNode();
00245     BOOL IsDifferent(AttributeValue *pAttr);
00246 
00247     // The arrow style
00248     ArrowRec StartArrow;
00249 
00250     static BOOL Init();
00251 };
00252 
00253 /********************************************************************************************
00254 
00255 >   class EndArrowAttribute : public AttributeValue
00256 
00257     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00258     Created:    26/01/94
00259     Purpose:    Attribute for end arrow type of paths.
00260     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00261                 StartArrowAttribute; StartCapAttribute; EndCapAttribute;
00262                 JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute;
00263                 DashPatternAttribute
00264 
00265 ********************************************************************************************/
00266 
00267 class EndArrowAttribute : public AttributeValue
00268 {
00269     CC_DECLARE_DYNCREATE(EndArrowAttribute)
00270 public:
00271     virtual void Restore(RenderRegion *, BOOL);
00272     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00273     virtual void SimpleCopy(AttributeValue *);
00274     virtual NodeAttribute *MakeNode();
00275     BOOL IsDifferent(AttributeValue *pAttr);
00276 
00277     // The arrow style
00278     ArrowRec EndArrow;
00279 
00280     static BOOL Init();
00281 };
00282 
00283 /********************************************************************************************
00284 
00285 >   class StartCapAttribute : public AttributeValue
00286 
00287     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00288     Created:    26/01/94
00289     Purpose:    Attribute for start cap style of paths.
00290     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00291                 StartArrowAttribute; EndArrowAttribute; EndCapAttribute;
00292                 JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute;
00293                 DashPatternAttribute
00294 
00295 ********************************************************************************************/
00296 
00297 class StartCapAttribute : public AttributeValue
00298 {
00299     CC_DECLARE_DYNCREATE(StartCapAttribute)
00300 public:
00301     StartCapAttribute();
00302 
00303     virtual void Restore(RenderRegion *, BOOL);
00304     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00305     virtual void SimpleCopy(AttributeValue *);
00306     virtual NodeAttribute *MakeNode();
00307     virtual BOOL IsDifferent(AttributeValue*);
00308 
00309     // The cap style
00310     LineCapType StartCap;
00311 
00312     static BOOL Init();
00313 };
00314 
00315 /********************************************************************************************
00316 
00317 >   class JoinTypeAttribute : public AttributeValue
00318 
00319     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00320     Created:    26/01/94
00321     Purpose:    Attribute for join types of paths.
00322     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00323                 StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00324                 MitreLimitAttribute; WindingRuleAttribute; DashPatternAttribute
00325 
00326 ********************************************************************************************/
00327 
00328 class JoinTypeAttribute : public AttributeValue
00329 {
00330     CC_DECLARE_DYNCREATE(JoinTypeAttribute)
00331 public:
00332     JoinTypeAttribute();
00333 
00334     virtual void Restore(RenderRegion *, BOOL);
00335     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00336     virtual void SimpleCopy(AttributeValue *);
00337     virtual NodeAttribute *MakeNode();
00338     virtual BOOL IsDifferent(AttributeValue*);
00339 
00340     // The join type
00341     JointType JoinType;
00342 
00343     static BOOL Init();
00344 };
00345 
00346 /********************************************************************************************
00347 
00348 >   class MitreLimitAttribute : public AttributeValue
00349 
00350     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00351     Created:    26/01/94
00352     Purpose:    Attribute for mitre limits of paths.
00353     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00354                 StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00355                 JoinTypeAttribute; WindingRuleAttribute; DashPatternAttribute
00356 
00357 ********************************************************************************************/
00358 
00359 class MitreLimitAttribute : public AttributeValue
00360 {
00361     CC_DECLARE_DYNCREATE(MitreLimitAttribute)
00362 public:
00363     MitreLimitAttribute();
00364 
00365     virtual void Restore(RenderRegion *, BOOL);
00366     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00367     virtual void SimpleCopy(AttributeValue *);
00368     virtual NodeAttribute *MakeNode();
00369     BOOL IsDifferent(AttributeValue *pAttr);
00370 
00371     // The mitre limit
00372     MILLIPOINT MitreLimit;
00373 
00374     static BOOL Init();
00375 };
00376 
00377 /********************************************************************************************
00378 
00379 >   class WindingRuleAttribute : public AttributeValue
00380 
00381     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00382     Created:    26/01/94
00383     Purpose:    Attribute for the winding rule of a path.
00384     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00385                 StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00386                 JoinTypeAttribute; MitreLimitAttribute; DashPatternAttribute
00387 
00388 ********************************************************************************************/
00389 
00390 class WindingRuleAttribute : public AttributeValue
00391 {
00392     CC_DECLARE_DYNCREATE(WindingRuleAttribute)
00393 public:
00394     WindingRuleAttribute();
00395     WindingRuleAttribute(WindingType NewRule) { WindingRule = NewRule; }
00396 
00397     virtual void Restore(RenderRegion *, BOOL);
00398     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00399     virtual void SimpleCopy(AttributeValue *);
00400     virtual NodeAttribute *MakeNode();
00401     virtual BOOL IsDifferent(AttributeValue*);
00402 
00403     // Winding rule
00404     WindingType WindingRule;
00405 
00406     static BOOL Init();
00407 };
00408 
00409 /********************************************************************************************
00410 
00411 >   class DashPatternAttribute : public AttributeValue
00412 
00413     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00414     Created:    26/01/94
00415     Purpose:    Attribute for dash pattern style of paths.
00416     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00417                 StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00418                 JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute
00419 
00420 ********************************************************************************************/
00421 
00422 class DashPatternAttribute : public AttributeValue
00423 {
00424     CC_DECLARE_DYNCREATE(DashPatternAttribute)
00425 public:
00426     DashPatternAttribute();
00427     ~DashPatternAttribute();
00428 
00429     BOOL SetDashPattern(DashRec& NewDash);
00430     BOOL SetStockDashPattern(StockDash NewDash);
00431     BOOL SetDeviceDashPattern(DashRec& NewDash, INT32 PixelSize);
00432     BOOL SetDeviceStockDashPattern(StockDash NewDash, INT32 PixelSize);
00433     INT32 operator==(DashPatternAttribute&);
00434 
00435     virtual void Restore(RenderRegion*, BOOL);
00436     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00437     virtual void SimpleCopy(AttributeValue*);
00438     virtual NodeAttribute* MakeNode();
00439     BOOL IsDifferent(AttributeValue *pAttr);
00440 
00441     // Dash pattern
00442     DashRec DashPattern;
00443 
00444     static BOOL Init();
00445 };
00446 
00447 /********************************************************************************************
00448 
00449 >   class DrawingModeAttribute : public AttributeValue
00450 
00451     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00452     Created:    26/01/94
00453     Purpose:    Attribute for drawing mode - EOR, COPY etc.
00454     SeeAlso:    FillColourAttribute; StrokeColourAttribute; LineWidthAttribute;
00455                 StartArrowAttribute; EndArrowAttribute; StartCapAttribute; EndCapAttribute;
00456                 JoinTypeAttribute; MitreLimitAttribute; WindingRuleAttribute
00457 
00458 ********************************************************************************************/
00459 
00460 class DrawingModeAttribute : public AttributeValue
00461 {
00462     CC_DECLARE_DYNCREATE(DrawingModeAttribute)
00463 public:
00464     DrawingModeAttribute() {}
00465     DrawingModeAttribute(DrawModeType NewDrawingMode) { DrawingMode = NewDrawingMode; }
00466 
00467     virtual void Restore(RenderRegion *, BOOL);
00468     virtual void Render(RenderRegion *, BOOL Temp = FALSE);
00469     virtual void SimpleCopy(AttributeValue *);
00470     virtual NodeAttribute *MakeNode();
00471     BOOL IsDifferent(AttributeValue *pAttr);
00472 
00473     // Drawing Mode
00474     DrawModeType DrawingMode;
00475     static UINT32 ID;
00476 };
00477 
00478 
00479 
00480 #endif // INC_ATTRVAL

Generated on Sat Nov 10 03:44:16 2007 for Camelot by  doxygen 1.4.4