00001 // $Id: cnamecol.h 751 2006-03-31 15:43:49Z alex $ 00002 // $Header: 00003 // CNamedColourReplacer class header 00004 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00005 ================================XARAHEADERSTART=========================== 00006 00007 Xara LX, a vector drawing and manipulation program. 00008 Copyright (C) 1993-2006 Xara Group Ltd. 00009 Copyright on certain contributions may be held in joint with their 00010 respective authors. See AUTHORS file for details. 00011 00012 LICENSE TO USE AND MODIFY SOFTWARE 00013 ---------------------------------- 00014 00015 This file is part of Xara LX. 00016 00017 Xara LX is free software; you can redistribute it and/or modify it 00018 under the terms of the GNU General Public License version 2 as published 00019 by the Free Software Foundation. 00020 00021 Xara LX and its component source files are distributed in the hope 00022 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00023 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00024 See the GNU General Public License for more details. 00025 00026 You should have received a copy of the GNU General Public License along 00027 with Xara LX (see the file GPL in the root directory of the 00028 distribution); if not, write to the Free Software Foundation, Inc., 51 00029 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00030 00031 00032 ADDITIONAL RIGHTS 00033 ----------------- 00034 00035 Conditional upon your continuing compliance with the GNU General Public 00036 License described above, Xara Group Ltd grants to you certain additional 00037 rights. 00038 00039 The additional rights are to use, modify, and distribute the software 00040 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00041 library and any other such library that any version of Xara LX relased 00042 by Xara Group Ltd requires in order to compile and execute, including 00043 the static linking of that library to XaraLX. In the case of the 00044 "CDraw" library, you may satisfy obligation under the GNU General Public 00045 License to provide source code by providing a binary copy of the library 00046 concerned and a copy of the license accompanying it. 00047 00048 Nothing in this section restricts any of the rights you have under 00049 the GNU General Public License. 00050 00051 00052 SCOPE OF LICENSE 00053 ---------------- 00054 00055 This license applies to this program (XaraLX) and its constituent source 00056 files only, and does not necessarily apply to other Xara products which may 00057 in part share the same code base, and are subject to their own licensing 00058 terms. 00059 00060 This license does not apply to files in the wxXtra directory, which 00061 are built into a separate library, and are subject to the wxWindows 00062 license contained within that directory in the file "WXXTRA-LICENSE". 00063 00064 This license does not apply to the binary libraries (if any) within 00065 the "libs" directory, which are subject to a separate license contained 00066 within that directory in the file "LIBS-LICENSE". 00067 00068 00069 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00070 ---------------------------------------------- 00071 00072 Subject to the terms of the GNU Public License (see above), you are 00073 free to do whatever you like with your modifications. However, you may 00074 (at your option) wish contribute them to Xara's source tree. You can 00075 find details of how to do this at: 00076 http://www.xaraxtreme.org/developers/ 00077 00078 Prior to contributing your modifications, you will need to complete our 00079 contributor agreement. This can be found at: 00080 http://www.xaraxtreme.org/developers/contribute/ 00081 00082 Please note that Xara will not accept modifications which modify any of 00083 the text between the start and end of this header (marked 00084 XARAHEADERSTART and XARAHEADEREND). 00085 00086 00087 MARKS 00088 ----- 00089 00090 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00091 designs are registered or unregistered trademarks, design-marks, and/or 00092 service marks of Xara Group Ltd. All rights in these marks are reserved. 00093 00094 00095 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00096 http://www.xara.com/ 00097 00098 =================================XARAHEADEREND============================ 00099 */ 00100 00101 #ifndef INC_NAMCOLREP 00102 #define INC_NAMCOLREP 00103 00104 class CCObject; 00105 class ColourFillAttribute; 00106 class DocColour; 00107 class TranspFillAttribute; 00108 00109 const INT32 MAX_TRANSP_VALUE = 255; 00110 00111 /******************************************************************************************** 00112 00113 > class CNamedColourReplacer : public CCObject 00114 00115 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00116 Created: 13/4/2000 00117 Purpose: This is a somewhat specialised class whose purpose is to temporarily replace the 00118 Named colours in a ColourFillAttribute. Its stores the colours that are replaced 00119 and can be called upon to put them back at a later time. 00120 It was designed for use with the Brush attribute, where we wish to be able to 00121 replace named colours in the brush objects, and then change them back. If you 00122 can think of any other uses for it then feel free. 00123 00124 ********************************************************************************************/ 00125 00126 class CNamedColourReplacer : public CCObject 00127 { 00128 CC_DECLARE_DYNCREATE(CNamedColourReplacer) 00129 00130 public: 00131 CNamedColourReplacer(); 00132 CNamedColourReplacer(ColourFillAttribute*, DocColour*); 00133 // if you use this constructor you can skip initialisation 00134 00135 ~CNamedColourReplacer(); 00136 00137 public: 00138 virtual BOOL Initialise(ColourFillAttribute*, DocColour*); 00139 00140 virtual BOOL IsInitialised(); 00141 00142 virtual BOOL ReplaceColours(); // replaces the named colours in the attribute 00143 virtual BOOL RestoreColours(); // restores the replaced colours 00144 00145 public: // Access fns. in case you change your mind after initialisation 00146 ColourFillAttribute* GetColourFill(); 00147 BOOL SetColourFill(ColourFillAttribute*); 00148 00149 DocColour* GetReplacementColour(); 00150 BOOL SetReplacementColour(DocColour*); 00151 00152 protected: //data 00153 ColourFillAttribute* m_pColourFill; 00154 DocColour* m_pReplaceColour; 00155 DocColour m_StartColour; 00156 DocColour m_EndColour1; 00157 DocColour m_EndColour2; 00158 DocColour m_EndColour3; 00159 }; 00160 00161 /******************************************************************************************** 00162 00163 > class CHSVChanger : public CNamedColourReplacer 00164 00165 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00166 Created: 17/4/2000 00167 Purpose: Similar to its parent class but adds the following options: 00168 - alter HSV values in existing colours, with no replacement colour 00169 - replace named colours (as parent class) and make HSV changes to all 00170 colours whether named or not. 00171 00172 Notes: This works by taking a multiplier value and calculating a fixed value that 00173 will be added or subtracted from each colour value. Values are in the range 00174 0 - 255, however Hue values can 'wrap - around' due to the colour wheel effect. 00175 ********************************************************************************************/ 00176 00177 class CHSVChanger : public CNamedColourReplacer 00178 { 00179 CC_DECLARE_DYNCREATE(CHSVChanger) 00180 00181 public: 00182 CHSVChanger(); 00183 CHSVChanger(ColourFillAttribute*, DocColour*); 00184 // if you use this constructor you can skip initialisation, though you will still need 00185 // to set the multipliers 00186 00187 ~CHSVChanger(); 00188 00189 public: 00190 virtual BOOL ReplaceColours(); // a safe way of accessing the base class function 00191 virtual BOOL RestoreColours(); // restores the replaced colours 00192 00193 BOOL ChangeHSVValues(); // does the HSV changing 00194 BOOL ShouldChangeHSV(); // indicates whether or not colours need changing 00195 00196 virtual BOOL IsInitialised(); 00197 00198 public: 00199 void ChangeColour(DocColour* pCol); // changes the values of just this colour 00200 00201 public: // access fns. 00202 double GetHueMultiplier(); 00203 BOOL SetHueMultiplier(double Value); 00204 00205 double GetSaturationMultiplier(); 00206 BOOL SetSaturationMultiplier(double Value); 00207 00208 protected: // helper fns. 00209 void ApplyIncrements(DocColour* pCol); 00210 00211 protected: //data 00212 double m_HueMultiplier; 00213 double m_SaturationMultiplier; 00214 double m_ValueMultiplier; 00215 00216 INT32 m_HueIncrement; // these can only be set internally 00217 INT32 m_SatIncrement; 00218 00219 protected: // storing the original values, this is a bit grim but given that we sometimes 00220 // have to clip values that go over 255 we cannot rely on the mults and incrs to undo the change 00221 DocColour m_OrigStartCol; 00222 DocColour m_OrigEndCol1; 00223 DocColour m_OrigEndCol2; 00224 DocColour m_OrigEndCol3; 00225 00226 }; 00227 00228 /******************************************************************************************** 00229 00230 > class CTransparencyReplacer : public CObject 00231 00232 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00233 Created: 27/6/2000 00234 Purpose: Similar to CNamedColourReplacer, this class takes a transparency attribute, changes 00235 its values, and then changes them back. 00236 00237 ********************************************************************************************/ 00238 00239 class CTransparencyReplacer : public CCObject 00240 { 00241 CC_DECLARE_DYNAMIC(CTransparencyReplacer) 00242 00243 public: 00244 CTransparencyReplacer(); 00245 ~CTransparencyReplacer() {}; 00246 00247 public: // access 00248 BOOL SetReplacementValue(INT32 Value); 00249 INT32 GetReplacementValue(); 00250 00251 BOOL SetAdjustmentValue(double Value); 00252 double GetAdjustmentValue(); 00253 BOOL SetInvertedAdjuster(double Value); 00254 double GetInvertedAdjuster(); 00255 00256 void SetTransparencyAttr(TranspFillAttribute* pAttr); 00257 BOOL ReplaceTransparency(); 00258 BOOL RestoreTransparency(); 00259 00260 BOOL IsInitialised(); 00261 protected: // data 00262 UINT32 m_OriginalTransp; // store the original value so we can replace it 00263 INT32 m_ReplaceTransp; // the replacement value, can be negative, indicating do nothing 00264 00265 double m_TranspAdjust; // adjusts the final value 00266 double m_InvertAdjust; // we now take a second adjuster which gets inverted 00267 00268 TranspFillAttribute* m_pTranspFill; // the transparency we're working on 00269 00270 00271 }; 00272 00273 00274 #endif